繁体   English   中英

CSS透明径向渐变问题

[英]CSS transparent radial gradient issue

我是CSS渐变的新手,并试图掌握它,我试图应用白色透明的CSS渐变来用背景图像围绕圆形div的边界。 不幸的是,我得到的效果不是所需要的,我该如何制作它,以使图像看起来不那么被渐变所遮盖,并且渐变不那么宽,我想让它仅影响图像的边界图像,例如距外环深约30像素。

我的代码:

 .transparent-gradient::after { content: ""; background-image: radial-gradient(ellipse at center, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); width: 100%; height: 100%; position: absolute; top: 0; left: 0; } .transparent-gradient{ width:300px; height:300px; margin:20px 0px; align-self:center;position:relative; overflow:hidden; background-color:red;border-radius:50%; background-size:cover; background-position:center; background-image:url('https://images.unsplash.com/photo-1530279281203-4c60af01ee58?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=02b66d237286bcb2a071ed6c1e72adf3&auto=format&fit=crop&w=1950&q=80'); } 
 <div class="transparent-gradient" style=""></div> 

 .transparent-gradient::after { content: ""; background: radial-gradient(ellipse at center, rgba(255,255,255,0) 40%,rgba(255,255,255,.9) 100%); width: 100%; height: 100%; position: absolute; top: 0; left: 0; } .transparent-gradient{ width:300px; height:300px; margin:20px 0px; align-self:center; position:relative; overflow:hidden; background-color:red; border-radius:50%; background-size:cover; background-position:center; background-image:url('https://images.unsplash.com/photo-1530279281203-4c60af01ee58?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=02b66d237286bcb2a071ed6c1e72adf3&auto=format&fit=crop&w=1950&q=80'); } 
 <div class="transparent-gradient" style=""></div> 

使用rgba(255,255,255,0) 40%40%指定“ 大小 ”。 使用rgba(255,255,255,.9) 100%的.9可使白色变硬(不透明/来自rgb A的 alpha值)。 1是完全白色.5是具有50%不透明度的white

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM