css和html中的图像和单选按钮对齐问题

时间:2012-05-01 16:34:36

标签: html css

我目前正在使用此代码:

<div style="width:200px; height:300px;">
<img src="./imgs/Apeiron-Island-Hotel.jpg" style="width:200px; height:200px;"/> <input align="middle" type="radio" name="venue"/></div>
<div style="width:200px; height:300px;">
<img src="./imgs/Apeiron-Island-Hotel.jpg" style="width:200px; height:200px;"/> <input align="middle" type="radio" name="venue"/></div>
<div style="width:200px; height:300px;">
<img src="./imgs/Apeiron-Island-Hotel.jpg" style="width:200px; height:200px;"/> <input align="middle" type="radio" name="venue"/></div>
它正在给我解决方案 http://i.stack.imgur.com/ppjjF.png 但我希望它像这样 http://i.stack.imgur.com/sIDX1.png

我从最近几个小时开始尝试,但我找不到任何解决方案。请帮助我

2 个答案:

答案 0 :(得分:1)

使用此

<style type="text/css">
.auto-style1 {
text-align: center;
display:inline-block
}

</style>

<div class="auto-style1" style="width: 200px; height: 300px; float: left">
    <img src="./imgs/Apeiron-Island-Hotel.jpg" style="width: 200px; height: 200px;">
    <input align="middle" name="venue" type="radio" ></div>
<div class="auto-style1" style="width: 200px; height: 300px; float: left">
    <img src="./imgs/Apeiron-Island-Hotel.jpg" style="width: 200px; height: 200px; float: left">
    <input align="middle" name="venue" type="radio" ></div>
<div class="auto-style1" style="width: 200px; height: 300px;">
    <img src="./imgs/Apeiron-Island-Hotel.jpg" style="width: 200px; height: 200px; float: left">
    <input align="middle" name="venue" type="radio" ></div>

答案 1 :(得分:0)

尝试这样的事情

    <div style="width:200px; height:300px; float:left; padding:0px 10px;" align="center">
    <img src="test.png" style="width:200px; height:200px;" /> <input align="middle" type="radio" name="venue"/></div>
    <div style="width:200px; height:300px; float:left; padding:0px 10px;" align="center">
    <img src="test.png" style="width:200px; height:200px;"/> <input align="middle" type="radio" name="venue"/></div>
    <div style="width:200px; height:300px; float:left; padding:0px 10px;" align="center">
    <img src="test.png" style="width:200px; height:200px;"/> <input align="middle" type="radio" name="venue"/></div>

检查Jsfiddle输出http://jsfiddle.net/8ZJP5/