我有一个设计,其中页面分为两部分,左侧包含图像,右侧包含一些文本。
问题是图像未填满左侧。
通常,我可以通过在图像上添加显示“块”来解决此问题,但这次没有帮助。
在这里您可以看到页面的代码: https://codepen.io/Lavonen/pen/vbOqdd
<!-- Left side -->
<div class="row">
<div class="column" style="background-color:#fff;">
<div class="image">
<img src="http://oncokdm.com/assets/barre.png" width="75%" height="auto" />
<img src="https://images.drivereasy.com/wp-content/uploads/2018/06/img_5b19100729335.jpg" width="75%" height="auto" />
</div>
</div>
<!-- Right side -->
<div class="column" style="background-color:#fff; text-align: left;">
<div class="content">
<div class="head">blablalba blablabla blablalba</div>
<div class="subh">blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba</div>
</div>
</div>
</div>
CSS:
.column
{
float: left;
width: 48%;
padding: 10px;
height: 100vh;
}
.column .image
{
margin-top: 22vh;
border: 1px solid #000;
}
.column .content
{
margin: 40vh 10vw 0 0;
}
.row:after
{
content: "";
display: table;
clear: both;
}
.column .content .head
{
margin: 25px 0 30px 0;
font-size: 1.3em;
font-family: 'Roboto', sans-serif;
color: #4a4a4a;
font-weight: 300;
}
.column .content .head:after {
content: '';
position: absolute;
display: block;
margin-top: 15px;
width: 40px;
height: 2px;
background: #004c71;
}
.column .content .subh
{
font-size: 1em;
font-family: 'Roboto', sans-serif;
color: #a8a8a8;
font-weight: 200;
line-height: 1.4;
}
@media screen and (max-width: 600px)
{
#section3 .column {
width: 100%;
}
}
答案 0 :(得分:1)
这显然是因为您拥有width="75%"
,这限制了它。设为width="100%"
。
<div class="image">
<img src="http://oncokdm.com/assets/barre.png" width="100%" height="auto" />
<img src="https://images.drivereasy.com/wp-content/uploads/2018/06/img_5b19100729335.jpg" width="100%" height="auto" />
</div>
这样做看起来像这样:
CodePen:https://codepen.io/anon/pen/pGJMwN
另一种方法是给图像加上边框,但是您需要处理浮点和布局,所以我觉得上述解决方案更好。
答案 1 :(得分:-1)
使用此代码,我还修复了其他帖子上显示的图像底部问题。
.column
{
float: left;
width: 48%;
padding: 10px;
height: auto;
}
.column .image {
margin-top: 22vh;
border: 1px solid #000;
display: inline-block;
}
.column .content
{
margin: 40vh 10vw 0 0;
}
.row:after
{
content: "";
display: table;
clear: both;
}
.column .content .head
{
margin: 25px 0 30px 0;
font-size: 1.3em;
font-family: 'Roboto', sans-serif;
color: #4a4a4a;
font-weight: 300;
}
.column .content .head:after {
content: '';
position: absolute;
display: block;
margin-top: 15px;
width: 40px;
height: 2px;
background: #004c71;
}
.column .content .subh
{
font-size: 1em;
font-family: 'Roboto', sans-serif;
color: #a8a8a8;
font-weight: 200;
line-height: 1.4;
}
.image img {
width: 100%;
float: left;
}
@media screen and (max-width: 600px)
{
#section3 .column {
width: 100%;
}
}
<!-- Left side -->
<div class="row">
<div class="column" style="background-color:#fff;">
<div class="image">
<img src="http://oncokdm.com/assets/barre.png" height="auto" />
<img src="https://images.drivereasy.com/wp-content/uploads/2018/06/img_5b19100729335.jpg" height="auto" />
</div>
</div>
<!-- Right side -->
<div class="column" style="background-color:#fff; text-align: left;">
<div class="content">
<div class="head">blablalba blablabla blablalba</div>
<div class="subh">blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba blablalba blablabla blablalba</div>
</div>
</div>
</div>