Jump to content
  • 0

radio и текст


html
 Share

Question

помогите, пожалуйста, кроссбраузерно (ие7 +, ff 1.5 +, google chrome, safari 3.0 +, opera 9.0) расположить текст справа от radio. пробовал так:

input.radio{float:left; margin:0 -18px 0 0;}
label{display:block; margin:-1px 0 3px 18px; font-size:14px;}

но в ие 7 текст смещается вниз ((

весь код:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
html{width:100%; height:100%;}
body{position:relative; width:1024px; height:100%; margin:0 auto; padding:0; color:#000; font:normal 11px Arial, Helvetica, sans-serif; line-height:1;}
html, div, dl, dt, dd, ul, li, ul li, h1, h2, p, form, fieldset, input, label, legend, img, a{margin:0; padding:0; border:0; outline:0; vertical-align:baseline;}
ul, li, ul li{list-style:none;}

.quest{margin:0 0 10px 0; color:#333; font-weight:bold; font-size:14px;}
input.radio{float:left; margin:0 -18px 0 0;}
label{display:block; margin:-1px 0 3px 18px; font-size:14px;}
</style>
</head>
<body>
<form action="">
<fieldset>
<div class="quest">Lorem ipsum dolor sit amet, consectetur adipiscing elit.?</div>
<ul>
<li>
<input type="radio" class="radio" name="vote" value="1" />
<label>Pellentesque id turpis at leo dapibus</label>
</li>
<li>
<input type="radio" class="radio" name="vote" value="2" />
<label>Pellentesque id turpis at leo dapibus</label>
</li>
<li>
<input type="radio" class="radio" name="vote" value="3" />
<label>Pellentesque id turpis at leo dapibus</label>
</li>
<li>
<input type="radio" class="radio" name="vote" value="4" />
<label>Pellentesque id turpis at leo dapibus</label>
</li>
</ul>
</fieldset>
</form>
</body>
</html>

п.с. с наступающим!

можно исправить margin'ом завернув код в комментарии, но хотелось бы один общий код.

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

иногда дизайн такой что чекбокс и радиоинпут без флота невыровнять кроссбраузерно.

Но если есть возможность то лучше не флотать а сделать так как показал psywalker

Link to comment
Share on other sites

  • 0

		.radio{float:left; width:16px; height:16; margin:0 8px 0 0; padding:0}
label{display:block; margin:-1px 0 3px 18px; font-size:14px;}

<form action="">
<fieldset>
<div class="quest">Lorem ipsum dolor sit amet, consectetur adipiscing elit.?</div>
<ul>
<li>
<label>
<input type="radio" class="radio" name="vote" value="1" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="2" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="3" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="4" />
Pellentesque id turpis at leo dapibus
</label>
</li>
</ul>
</fieldset>
</form>

1262255363_radio.jpg

Link to comment
Share on other sites

  • 0

Вопервых если флотаешь то родителю overflow:hidden;

<label><input type="radio" name="vote"  />Pellentesque id turpis at leo dapibus</label>

Сделай такой хтмл, убери все стили. И заново пиши стили, тогда быстрее поймешь что как работает.

Хотя как по мне сунуть инпуты в лейблы это неправильно.

Link to comment
Share on other sites

  • 0

С новым годом!

теперь смещение идёт вниз во всех браузерах кроме ие 7

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
html{width:100%; height:100%;}
body{position:relative; width:1024px; height:100%; margin:0 auto; padding:0; color:#000; font:normal 11px Arial, Helvetica, sans-serif; line-height:1;}
html, div, dl, dt, dd, ul, li, ul li, h1, h2, p, form, fieldset, input, label, legend, img, a{margin:0; padding:0; border:0; outline:0; vertical-align:baseline;}
ul, li, ul li{list-style:none;}
fieldset{overflow:hidden; width:100%;}

.quest{margin:0 0 10px 0; color:#333; font-weight:bold; font-size:14px;}
.radio{width:16px; height:16px; margin:0 3px 0 0; padding:0;}
label{font-size:14px;}
</style>
</head>
<body>
<form action="">
<fieldset>
<div class="quest">Lorem ipsum dolor sit amet, consectetur adipiscing elit.?</div>
<ul>
<li>
<label>
<input type="radio" class="radio" name="vote" value="1" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="2" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="3" />
Pellentesque id turpis at leo dapibus
</label>
</li>
<li>
<label>
<input type="radio" class="radio" name="vote" value="4" />
Pellentesque id turpis at leo dapibus
</label>
</li>
</ul>
</fieldset>
</form>
</body>
</html>

1262506612_ii.jpg

Link to comment
Share on other sites

  • 0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body{
margin:0;
font:14px Arial, Helvetica,sans-serif;
}
form,fieldset{
margin:0;
padding:0;
border:0;
}
form{
line-height:16px;
}
ul{
list-style:none;
margin:40px;
padding:0;
}
li{
overflow:hidden;
_zoom:1;
}
.radio{
width:16px;
height:15px;
margin:0 3px 0 0;
padding:0;
vertical-align:middle;
float:left;
}
</style>
</head>
<body>
<form action="#">
<fieldset>
<ul>
<li><label><input type="radio" class="radio" name="vote" />Pellentesque id turpis at leo dapibus</label></li>
<li><label><input type="radio" class="radio" name="vote" />Pellentesque id turpis at leo dapibus</label></li>
<li><label><input type="radio" class="radio" name="vote" />Pellentesque id turpis at leo dapibus</label></li>
<li><label><input type="radio" class="radio" name="vote" />Pellentesque id turpis at leo dapibus</label></li>
</ul>
</fieldset>
</form>
</body>
</html>

Так пойдет?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy