首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用css实现这种模糊效果

问如何使用css实现这种模糊效果
EN

Stack Overflow用户
提问于 2020-10-09 23:15:02
回答 3查看 107关注 0票数 0

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

​

EN

回答 3

Stack Overflow用户

发布于 2020-10-10 00:35:41

给定的图像看起来并不像问题中提到的CSS投影,而更像是放在元素中的图像,元素的顶部是一个带有线性渐变的div,甚至是线性渐变的倍数,半透明。

这类事情

代码语言:javascript
复制
background-image: linear-gradient(to bottom right, rgba(0,0,0,0.5),rgba(255,255,255,0.5));

但更复杂。玩弄色调、不透明度和位置可能是获得所需内容的唯一方法,线性梯度的好处是它们可以让你做到这一点。

票数 0
EN

Stack Overflow用户

发布于 2020-10-10 01:12:27

您可以使用SVG图像来实现此目的。您可以在CSS文件中添加SVG图像,也可以在HTML文件中添加SVG代码。我无法在此附加SVG文件。

这是最终的输出。

​

​

代码语言:javascript
复制
    <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>
票数 0
EN

Stack Overflow用户

发布于 2020-10-10 01:31:50

我使用了.splash容器的伪元素,使其小于其父容器。在这个伪元素上,我有一个部分透明的背景和一个长方体阴影。

我确实需要将所述容器的所有子容器放在伪类的顶部。

如您所见,在包含所有文本的父元素的边缘之前,背景开始淡入淡出。

​

代码语言:javascript
复制
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);
}
代码语言:javascript
复制
<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>

​

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64282774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档