html - 我可以将框阴影自定义为图像后面的三角形吗?
问题描述
我正在尝试自定义一个盒子阴影,使其形状像图像后面的三角形。像这样:
但我不知道是否有办法使用盒子阴影来做到这一点。
到目前为止,这是我的代码。
#image{
width: 200px;
box-shadow: -10px 10px #ff9900;
}
<img src="https://placeimg.com/200/180/any" id="image" />
解决方案
一个简单的渐变边框就可以了,它会响应:
#image {
border: 10px solid transparent;
border-image: linear-gradient(to bottom left, transparent 60%, #ff9900 60.5%) 10;
}
<img src="https://placeimg.com/180/150/any" id="image" />
<img src="https://placeimg.com/250/150/any" id="image" />
几乎相同,但有背景:
.box{
width:200px;
height:150px;
padding:10px; /*control the space*/
background:
url(https://placeimg.com/180/150/any) center/cover content-box,
linear-gradient(to bottom left, transparent 60%, #ff9900 60.5%);
}
<div class="box"></div>
推荐阅读
- python - 如何在 Azure ML 服务计算集群上并行工作?
- r - data.table 中行的条件操作和扩展还考虑了以前没有 for 循环的扩展
- c - 将 RData 文件导入 C
- hyperlink - 为什么 gatsby 的 Link 组件的 activeClassName 不适用于我的锚链接?
- swift - 在 AVAudioPlayer 中播放音调时如何在循环之间添加延迟?
- php - Wordpress 中的当前级别导航
- swift - NSURLErrorDomain:-1003
- prestashop-1.7 - 我无法在没有登录的情况下查看类别
- aem - 如何在待机模式下修复 AEM Author 上的“handleLoginFailure”
- angular - 角 | 如何以另一个组件的形式显示对象