我试图得到这个云状/高斯蓝效果,但我不能完全得到它。我试过使用相同背景颜色的阴影,但它并不完全正确。有人知道怎么做吗?

发布于 2020-10-10 00:35:41
给定的图像看起来并不像问题中提到的CSS投影,而更像是放在元素中的图像,元素的顶部是一个带有线性渐变的div,甚至是线性渐变的倍数,半透明。
这类事情
background-image: linear-gradient(to bottom right, rgba(0,0,0,0.5),rgba(255,255,255,0.5));但更复杂。玩弄色调、不透明度和位置可能是获得所需内容的唯一方法,线性梯度的好处是它们可以让你做到这一点。
发布于 2020-10-10 01:12:27
您可以使用SVG图像来实现此目的。您可以在CSS文件中添加SVG图像,也可以在HTML文件中添加SVG代码。我无法在此附加SVG文件。
这是最终的输出。

<style>
body{
/*background-image: url("#"); Add background Image*/
background-repeat: no-repeat;
background-size: 100%;
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
margin: 0 auto;
max-width: 800px;
max-height: 800px;
}
.container{
width: 800px;
height: 800px;
/*background-image: url(".svg");*/
/*or .svg code in html file*/
background-repeat: no-repeat;
}
</style>
<body>
<div class="container"></div>
</body>发布于 2020-10-10 01:31:50
我使用了.splash容器的伪元素,使其小于其父容器。在这个伪元素上,我有一个部分透明的背景和一个长方体阴影。
我确实需要将所述容器的所有子容器放在伪类的顶部。
如您所见,在包含所有文本的父元素的边缘之前,背景开始淡入淡出。
section {
height: 200px;
display: flex;
justify-content: center;
align-items: center;
background-color: #121212
}
.splash {
--splash-background-color: rgba(255, 255, 255, 0.3);
--splash-background-size-decrement: 60px;
position: relative;
z-index: 2;
}
.splash > * {
position: relative;
z-index: 1;
}
.splash::before {
content: '';
position: absolute;
left: var(--splash-background-size-decrement);
right: var(--splash-background-size-decrement);
top: var(--splash-background-size-decrement);
bottom: var(--splash-background-size-decrement);
background-color: var(--splash-background-color);
box-shadow: 0px 0px 50px 60px var(--splash-background-color);
}<section>
<div class="splash">
<h1>Some text here</h1>
<p>Some text here. Some text here</p>
<p>Some text here. Some text here</p>
</div>
<section>
https://stackoverflow.com/questions/64282774
复制相似问题