我努力呈现两个水平对齐的图像,下面是文字。这是我的代码:
HTML
<div class="selectGame">
<div id="computerIcon" class = "icon">
<img src="http://lorempixel.com" >
<span class ="iconText"><p>VS Computer</p></span>
</div>
<div id="humanIcon" class = "icon">
<img src="http://lorempixel.com" >
<span class ="iconText"><p>VS Human</p></span>
</div>
</div>
CSS
.icon img{
float: left;
width: 40%;
}
.iconText p{
clear: both;
}
答案 0 :(得分:0)
把浮动:左边和宽度:40%放在.icon类而不是.icon img - so
上.icon {
float: left;
width: 40%;
}
答案 1 :(得分:0)