我创建了一个带有图像的网格,就像我在项目中使用了flexbox一样。CSS网格 - 1px边框。我无法获得边框效果
.container {
box-sizing: border-box;
margin: 0 auto;
max-width: 1156px;
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.box {
box-sizing: border-box;
border: 1px solid #000;
/* padding: 10px; */
margin-right: -1px;
margin-bottom: -1px;
position: relative;
}
img {
max-width: 100%;
margin: 10px;
}
.cell img {
display: block;
}
@media only screen and (min-width: 768px) {
.container {
flex-direction: row;
}
/* .box {
width: 50%;
} */
}
@media only screen and (min-width: 1024px) {
.box {
width: calc(100%/4);
}
}
<div class="container">
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div class="box">
<div class="cell">
<img src="http://placehold.it/270x270">
</div>
</div>
<div>
在创建网格我不得不使用负利润率右侧和底部。
但是我有一个问题,大意是:悬停在与透明度图像和边框颜色叠加。 (:网格显示)
我也使用CSS网格布局制成的网格。
.container {
width: 100%;
height: 100%;
}
img {
max-width: 100%;
display: block;
}
.grid {
\t display: grid;
\t grid-row-gap: 1px;
\t background-color: #000;
\t border: 1px solid #000;
\t grid-gap: 1px;
\t justify-self: center;
\t max-width: 290px;
\t height: auto;
\t margin: 0 auto;
}
.grid > div {
\t border: 10px solid #fff;
}
@media only screen and (min-width: 768px) {
\t .grid {
\t \t grid-template-columns: repeat(2, 1fr);
\t \t grid-template-rows: repeat(4, 1fr);
\t \t max-width: 581px;
\t }
}
@media only screen and (min-width: 1024px) {
\t
\t .grid {
\t \t grid-template-columns: repeat(4, 1fr);
\t \t grid-template-rows: repeat(2, 1fr);
\t \t max-width: 1163px;
\t }
}
<div class="container">
<div class="grid">
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
<div><img src="http://placehold.it/270x270"></div>
</div>
</div>
请帮助我怎样才能得到这些效果。
谢谢。
当有人把自己的自由业余时间帮您排忧解难,在我的书,你在一个或其他方式表示感谢,因为你却反其道而行之,并张贴完成同样的解决方案后,我现在决定删除我的答案。我希望下一次你真的需要别人帮助你。 – LGSon