html - 把文字放在图片的右边

标签 html css

我怎样才能把文字放在图片的右边,看起来像这样:http://i.imgur.com/3hDi0mW.png .我尝试过使用 clear、float.. 很多命令.. 但对我来说,它不起作用..

enter image description here

你能帮帮我吗?谢谢 :) 这是我的代码:

#subcontent {
  margin: 0 auto;
  width: 70%;
  border-top: 1px solid #ececec;
  background-color: red;
}
.person {
  float: left;
  display: block;
  margin: 0 auto;
  width: 35%;
}
p {
  font-size: 12px;
  clear: right;
  float: left;
}
.group2 {
  overflow: hidden;
  margin: 0 auto;
}
.person2 {
  float: left;
  display: block;
  margin: 0 auto;
  width: 35%;
}
.textwrap {
  float: left;
  clear: left;
}
<div id="subcontent">
  <div class="group2">
    <div class="person">
      <img class="textwrap" src="http://i.imgur.com/zzqeeyc.png">

      <p>A creative man is motivated by the desire to achieve, not by the desire to beat others. Jane Goodall - Residential Customer</p>
    </div>

    <div class="person2">
      <img class="textwrap" src="http://i.imgur.com/zzqeeyc.png">

      <p>A creative man is motivated by the desire to achieve, not by the desire to beat others. Jane Goodall - Residential Customer</p>
    </div>

  </div>
</div>

最佳答案

删除 float 并在 width 中更改一些 % 的大小

#subcontent {
    margin: 0 auto;
    width: 100%;
    border-top: 1px solid #ececec;
    background-color: red;
}

.person {
    float:left;
    margin: 0 auto;
    width: 50%;
   
}
p{
    font-size: 12px;
    display: block;
    line-height: 18px;
}
.group2 {
    overflow: hidden; 
    margin: 0 auto;
 }
.person2 {
    float:left;
    display: block;
    margin: 0 auto;
    width: 50%;  
}
.textwrap {
    float:left;
    margin-right: 15px;
}
<div id="subcontent">
<div class="group2">
<div class="person">
<img  class="textwrap" src="http://i.imgur.com/zzqeeyc.png">
 
  <p>A creative man is motivated by the desire to achieve, not by the desire to beat others.

 Jane Goodall - Residential Customer</p>
 </div>

<div class="person2">
<img class="textwrap" src="http://i.imgur.com/zzqeeyc.png">
 
  <p>A creative man is motivated by the desire to achieve, not by the desire to beat others.

 Jane Goodall - Residential Customer</p>
 </div>

</div>
</div>

关于html - 把文字放在图片的右边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39697821/

相关文章:

html - 在 Django 中加载基于 Bootstrap 的主页时出现 404 错误

css - 合并 CSS IE 调用

javascript - 使用 jquery 将 div 类定位在另一个 div 旁边

html - 如何在导航栏右侧使用偏移量

html - 悬停多级下拉

javascript - 如何检测元素是否在其容器之外?

html - 如何使表格单元格不占用空间?

javascript - HTML 导航链接复制表单通过单击图像按钮提交

javascript - 如何使字母的赌场式增量?

javascript - 在 for 循环中使用 jQuery 更改 div css 值