上面是1920宽度浏览器上的屏幕截图。本质上这是我想要的布局,但是当我调整浏览器的大小时,它看起来像这样:
我希望这些框在各个部分的左侧和右侧之间没有白色间距,并且在有/无间距的情况下,它们都保持相同的100%宽度。
我意识到间距的产生是因为代码的设置方式,中间部分的边距将其推开,但是我不确定如何设置此功能以实现第一个屏幕截图和此效果。
小提琴:https : //jsfiddle.net/jzhang172/r641pmzb/
body,
html {
margin: 0px;
font-family: lato-reg;
font-size: 16px;
color: #3c3c3c;
overflow-x: hidden;
}
img {
width: 100%;
height: 100%;
}
.section {
position: relative;
}
/*--------------------------------------Fifth Section--*/
.flex-container {
margin-top: 10px;
width: 100%;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.work-indiv {
width: 540px;
-webkit-flex: auto;
-ms-flex: auto;
flex: auto;
display: inline-block;
height: 237px;
position: relative;
margin-bottom: 10px;
cursor: pointer;
transition: 1s;
}
.work-indiv:hover img {
opacity: .6;
transition: .6s;
}
.middle {
padding-left: 10px;
padding-right: 10px;
width: 783px;
}
.work-indiv span {
position: absolute;
clear: both;
bottom: 0;
left: 0;
color: White;
margin-left: 40px;
text-transform: uppercase;
margin-bottom: 40px;
font-size: 2.125em;
font-family: latobold;
letter-spacing: .16em;
}
.middle span {
margin-left: 50px;
}
<div class="section" id="fifth">
<div class="flex-container">
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Topworkz">
<span>Topworkz</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Joint">
<span>Joint</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Market">
<span>Market</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Worktop">
<span>Worktop</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Lable">
<span>Lable</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="KYIV">
<span>KYIV</span>
</div>
</div>
尝试在媒体查询中删除左侧和右侧padding
,.middle
以缩小屏幕尺寸。
您的代码中包含以下内容:
.middle {
padding-left: 10px;
padding-right: 10px;
width: 783px;
}
尝试此调整:
@media screen and ( max-width: 1200px) {
.middle {
padding-left: 0;
padding-right: 0; }
}
现在,当屏幕尺寸小于1200px宽时,将删除填充。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句