简体   繁体   English

响应式3 div与图像并排

[英]responsive 3 div side by side with image

How to align image and content inside div under div. 如何在div下对齐div中的图像和内容。 tried with float left but not working 尝试浮动左但不起作用

Js fiddle link for quick overview JS小提琴链接可快速概览
here is the CSS: 这是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: 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>

Floating image to the left seems to be working just fine: http://jsfiddle.net/rTZJ9/ . 左侧的浮动图像似乎工作正常: http : //jsfiddle.net/rTZJ9/

.col > img {
    float: left;
}

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

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

@Sharanpreet The align attribute of is not supported in HTML5. @Sharanpreet HTML5不支持的align属性。 Use CSS instead. 改用CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM