- 5
- 4
- 3
- 1
- 8
- 0
- 0
- 0
- 1
- 3
- 2
Верстаем вложенные поля

Привет, сегодня я буду объяснять как сверстать вложенные input-поля, такого вида:

Итак, приступим!
Начнем с html кода:
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Новый Документ</title>
<style></style>
</head>
<body>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Новый Документ</title>
<style></style>
</head>
<body>
</body>
</html>
Создали основной макет, теперь приступаем к написанию самих input`ов и их оформления. В
Code
<!-- создаем див родителя -->
<div class="all">
<div class="input_text relative">
<!-- само поле -->
<input type="text" id="txt" value="Это input поле…"/>
<!-- родитель кнопки -->
<div class="button">
<!-- кнопка -->
<input type="button" id="butt"/>
</div>
</div>
</div>
<div class="all">
<div class="input_text relative">
<!-- само поле -->
<input type="text" id="txt" value="Это input поле…"/>
<!-- родитель кнопки -->
<div class="button">
<!-- кнопка -->
<input type="button" id="butt"/>
</div>
</div>
</div>
После, переходим в написанию CSS:
Code
<style>
.relative{
position:relative
}
.input_text{
width:187px!important/* чтобы поле имело ширину точно 200px */
}
.input_text input{
width:100%;
height:20px;
border:1px solid #969696;
-moz-border-radius:20px;/* для Firefox */
-webkit-border-radius:20px;/* для Chrome, Safari */
border-radius:20px;/* для Opera */
padding-left:10px/* отступ для текста */
}
.button input{
cursor:hand;/* при наведении на кнопку, будет курсор «руки» */
width: 16px;
height: 16px;
background: url(search_icon.png) no-repeat;/* указываю фон */
border:none!important;/* убираю лишнюю обводку */
position:absolute;/* абсолюбно позиционирую */
top:4px;
right:-5px
}
</style>
.relative{
position:relative
}
.input_text{
width:187px!important/* чтобы поле имело ширину точно 200px */
}
.input_text input{
width:100%;
height:20px;
border:1px solid #969696;
-moz-border-radius:20px;/* для Firefox */
-webkit-border-radius:20px;/* для Chrome, Safari */
border-radius:20px;/* для Opera */
padding-left:10px/* отступ для текста */
}
.button input{
cursor:hand;/* при наведении на кнопку, будет курсор «руки» */
width: 16px;
height: 16px;
background: url(search_icon.png) no-repeat;/* указываю фон */
border:none!important;/* убираю лишнюю обводку */
position:absolute;/* абсолюбно позиционирую */
top:4px;
right:-5px
}
</style>
Начнем с
Соответственно пример. Спасибо за внимание.
Дата: 03.07.2010 • Теги:
поле, css, html, body, input, position, absolute, relative, border-radius
↑ +5 ↓
- Не найдено.
#1:
maivan
03.07.2010, 23:48
#3
@Foggy рад стараться.
UnderShot
#4:
Aleko
04.07.2010, 01:59
#5
@Aleko ага, это я и хотел спросить у тебя. В асю зайди.
UnderShot
#7:
ad
04.07.2010, 15:29
#8
@ad у тебя браузер не поддерживает border-radius.
UnderShot
#9:
IDiz
04.07.2010, 17:39
#10
@IDiz это уже каждый для под себя будет подстраивать.
UnderShot
#12
@Rebelion эдакая фишка
UnderShot
UnderShot


