如何将pic与单选按钮的同一行对齐?

时间:2014-10-20 04:25:07

标签: html css radio-button inline

我已经完成浮动和内联但不起作用。希望你们帮助我。 它就像这样

<form action="#">
<input type="radio" class="inline" name="pay" value="visa"><img src="pic1.gif">
<input type="radio" class="inline" name="pay" value="master"><img src="pic2.gif">
<input type="radio" class="inline" name="pay" value="paypal"><img src="pic3.jpg">
</form>

* * *

the output goes like this:
         ---------
         '  pic  '
         '-------'


     *radio

i want it to be like this:
             ---------
      *radio '  pic  '
             '-------'

CSS:

.inline {
    display: inline-block;
}

3 个答案:

答案 0 :(得分:1)

定义 input radioimg标记此css

    .inline,.inline + img{
     display:inline-block;
   vertical-align:middle
    } 

<强> Demo

答案 1 :(得分:0)

使用vertical-align:middle; float:left;

答案 2 :(得分:0)

vertical-align:middle用于img代码

<强> HTML

<form action="#">
    <input type="radio" class="inline" name="pay" value="visa"><img src="http://www.m8betting.com/M8betting/Upload/3746/thumbs/image_placeholder8.gif">
    <input type="radio" class="inline" name="pay" value="master"><img src="http://www.m8betting.com/M8betting/Upload/3746/thumbs/image_placeholder8.gif">
    <input type="radio" class="inline" name="pay" value="paypal"><img src="http://www.m8betting.com/M8betting/Upload/3746/thumbs/image_placeholder8.gif">
</form>

<强> CSS

img{
    vertical-align:middle;
}

Fiddle Sample