我正在使用 html和css 构建水平多列布局,我试图在框中添加叠加渐变div但是我&# 39; m面临一个奇怪的问题: 覆盖div在FF / IE11 / Edge / Safari中的所有块上看起来都很好但是从右上方块中消失只有chrome 。
HTML / CSS代码:
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.wrapper { width:90%; max-width:1130px; margin:auto; padding:3em 0; }
.masonry, .inner {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
-moz-column-gap: 30px;
-webkit-column-gap: 30px;
column-gap: 30px;
}
.masonry article.brick { width:100%; height:300px; }
.inner article { width:100%; height:150px; }
.masonry article { margin-bottom: 30px; border:1px solid red; }
.masonry article { position:relative; } .masonry article a { color:red; }
.masonry article h3 { position:absolute; bottom:30px; margin-left: auto; margin-right: auto; left: 0;right: 0; width:90%; z-index:5; }
.masonry .inner article h3 { bottom:0px;}
.overlay{ width:100%; height:100%; position:absolute; background:linear-gradient(rgba(0,0,0,0), rgba(0,0,0,1)); opacity:0.9; z-index:3; transition: all .3s; }

<div class="wrapper">
<div class="masonry">
<article class="brick"><a href="#"><h3>Post Title - Big</h3><div class="overlay"></div></a></article>
<div class="inner">
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
</div>
<article class="brick"><a href="#"><h3>Post Title - Big</h3><div class="overlay"></div></a></article>
</div>
</div>
&#13;
答案 0 :(得分:1)
非常奇怪,我倾向于这是一个错误。但是,作为修复,请不要使用.inner
。在渐变中设置不透明度以淡化它。
似乎与您格式化* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.wrapper { width:90%; max-width:1130px; margin:auto; padding:3em 0; }
.masonry, .inner {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
-moz-column-gap: 30px;
-webkit-column-gap: 30px;
column-gap: 30px;
}
.masonry article.brick { width:100%; height:300px; }
.inner article { width:100%; height:150px; }
.masonry article { margin-bottom: 30px; border:1px solid red; }
.masonry article { position:relative; } .masonry article a { color:red; }
.masonry article h3 { position:absolute; bottom:30px; margin-left: auto; margin-right: auto; left: 0;right: 0; width:90%; z-index:5; }
.masonry .inner article h3 { bottom:0px;}
.overlay{ width:100%; height:100%; position:absolute; background:linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.9)); z-index:3; transition: all .3s; }
的方式以及您对列的使用有关。
<div class="wrapper">
<div class="masonry">
<article class="brick"><a href="#"><h3>Post Title - Big</h3><div class="overlay"></div></a></article>
<div class="inner">
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
<article><a href="#"><h3>Post Title - Sub</h3><div class="overlay"></div></a></article>
</div>
<article class="brick"><a href="#"><h3>Post Title - Big</h3><div class="overlay"></div></a></article>
</div>
</div>
{{1}}