我正在尝试制作一个透明的固定头,没有JS,只有CSS。我有一个例子,其中使用::before
制作具有负z-index
的模糊基板。
https://jsfiddle.net/VeryDeepSky/w8a93wpu/
但我只是失败了。。。那么多次。。。同时,我已经知道如何使用jQuery。我正在寻找CSS解决方案。有人能帮忙吗?
谢谢!
附言:这是我想做的。
https://jsfiddle.net/VeryDeepSky/81f7wcwh/6/
我找到了一个背景图像的解决方案,但我不知道如何将模糊效果应用于标题下的所有元素。
.content:before {
content: '';
display: block;
position: fixed;
left: 0;
right: 0;
top: -5px;
height: 100px;
background-image: url('http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_527bf56961712_1.JPG');
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
.content {
background-image: url('http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_527bf56961712_1.JPG');
background-attachment: fixed;
left: 0;
right: 0;
width: 1200px;
height: 800px;
}
p:first-child {
padding-top: 100px;
}
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquam erat in ante malesuada, facilisis semper nulla semper. Phasellus sapien neque, faucibus in malesuada quis, lacinia et libero. Sed sed turpis tellus. Etiam ac aliquam tortor, eleifend
rhoncus metus. Ut turpis massa, sollicitudin sit amet molestie a, posuere sit amet nisl. Mauris tincidunt cursus posuere. Nam commodo libero quis lacus sodales, nec feugiat ante posuere. Donec pulvinar auctor commodo. Donec egestas diam ut mi adipiscing,
quis lacinia mauris condimentum. Quisque quis odio venenatis, venenatis nisi a, vehicula ipsum. Etiam at nisl eu felis vulputate porta.</p>
<p>Fusce ut placerat eros. Aliquam consequat in augue sed convallis. Donec orci urna, tincidunt vel dui at, elementum semper dolor. Donec tincidunt risus sed magna dictum, quis luctus metus volutpat. Donec accumsan et nunc vulputate accumsan. Vestibulum
tempor, erat in mattis fringilla, elit urna ornare nunc, vel pretium elit sem quis orci. Vivamus condimentum dictum tempor. Nam at est ante. Sed lobortis et lorem in sagittis. In suscipit in est et vehicula.</p>
</div>