响应3 div与图像并排

时间:2014-07-27 01:00:46

标签: html css html5 css3 responsive-design

如何在div下对齐div中的图像和内容。尝试浮动但不工作

Js fiddle link快速浏览 这是CSS:

.container {
   clear: both;
   padding: 0px;
   margin: 0px;
  overflow:hidden;
 }
.profile1 {
  background-color: #CCF;
 }
.profile2 {
 background-color: #CFC;
}
.profile3 {
 background-color: #FCC;
}
@media only screen and (min-width: 480px) {
 .span_1_of_3 {
  width: 32.2%;
}
.col {
  display: block;
  float: left;
  margin: 1% 0 1% 1.6%;
}
.col:first-child {
 margin-left: 0;
}
}


HTML:

<div class="container" style="border:2px solid black;">
    <div class="col span_1_of_3 profile1"><img src="http://placehold.it/100x100"/>Lorem ipsum dolor sit amet</div>
    <div class="col span_1_of_3 profile2"><img src="http://placehold.it/100x100"/>Lorem ipsum dolor sit amet</div>
    <div class="col span_1_of_3 profile3"><img src="http://placehold.it/100x100"/>Lorem ipsum dolor sit amet</div>
</div>

3 个答案:

答案 0 :(得分:1)

向左浮动图像似乎工作得很好:http://jsfiddle.net/rTZJ9/

.col > img {
    float: left;
}

答案 1 :(得分:0)

DRD的aswer很好,您也可以在align="left"标记内使用img

<img src="http://placehold.it/100x100" align="left"/>

答案 2 :(得分:0)

@Sharanpreet HTML5中不支持align属性。请改用CSS。