html - 在 Chrome 中使用多列布局中断覆盖 div

标签 html css google-chrome

我正在使用 仅使用 html 和 css 构建一个水平多列布局,我正在尝试向框添加叠加渐变 div,但我正面临一个奇怪的问题: Overlay div 在 FF/IE11/Edge/Safari 中的所有 block 上看起来都不错,但仅从右上角的 block chrome 中消失

Chrome Preview

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>

代码笔:http://codepen.io/anon/pen/wgegxp

最佳答案

很奇怪,我倾向于这是一个错误。但是,作为解决方法,不要使用 opacity。设置渐变本身的不透明度以使其淡化。

似乎与您格式化 .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>

关于html - 在 Chrome 中使用多列布局中断覆盖 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41814080/

相关文章:

javascript - chrome.tabs.Tab 未在 popup.js 脚本中定义

google-chrome - 嵌入式 Vimeo(iframe)全屏在 chrome 中不起作用

javascript - Chrome DOM 未针对 jQuery 附加/淡入更新

html - 如何仅将类型 ="number"设为正数

html - iphone 浏览器中基于 Bootstrap 的表单的设计问题

javascript - W3C 和/或加载非可视网页资源的公认标准

html - 如何将按钮放置在带有扩展内容的窗口底部

html - 如何使纯 css float 工具提示(绝对定位跨度)动态调整大小以适应文本

html - 在 Google Chrome 中看不到 Logo ,但在 IE 和 Firefox 中可以

php - 根据用户输入更新mysql数据库