[英]How to get a gradient border on two half sides of a image, as shown in attached image
My code:我的代码:
body { height: 100vh; margin: 0; display: grid; place-items: center; background: #000000; }.module-border-wrap { max-width: 320px; padding: 1rem; position: relative; background: linear-gradient(130deg, rgba(248,253,254,1) 50%, rgba(33,186,227,1) 100%); padding: 6px; border-radius: 1.5rem 1.5rem 0 1.5rem; }.module { background: #ffffff; color: #000000; padding: 2rem; border-radius: 1.5rem 1.5rem 0 1.5rem; }.w-100{ width:100; }.p-0{ padding:0; }.relative{ position: relative; }.curved{ border-radius: 30px 30px 0 30px; }
<div class="module-border-wrap"> <div class="module p-0 relative curved"> <img src="https://picsum.photos/300/200" class="w-100 curved" alt=""> </div> </div>
So far, I am able to get the gradient, however, its showing outside of image, unlike in the attached screenshot, where the gradient border is over the image itself.到目前为止,我能够获得渐变,但是,它显示在图像外部,这与附加的屏幕截图不同,渐变边框位于图像本身之上。
You can try using one pseudo element and multiple backgrounds您可以尝试使用一个伪元素和多个背景
body { height: 100vh; margin: 0; display: grid; place-items: center; background: #000000; }.box { border-radius: 1.5rem 1.5rem 0 1.5rem; overflow: hidden; display: flex; position: relative; }.box:before { content:""; position:absolute; inset: 0; --g: #0000 1.8rem,#21bae3; /* update the color here */ --t: 10px; /* the thickness of the gradient */ background: linear-gradient( 90deg,var(--g)) bottom/100% var(--t), linear-gradient(180deg,var(--g)) right /var(--t) 100%; background-repeat: no-repeat; }
<div class="box"> <img src="https://picsum.photos/300/200" > </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.