我怎样才能把文字放在图片的右边,看起来像这样:http://i.imgur.com/3hDi0mW.png .我尝试过使用 clear、float.. 很多命令.. 但对我来说,它不起作用..
你能帮帮我吗?谢谢 :) 这是我的代码:
#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/