CSS3实现翘边的阴影效果的代码示例
网站建设 2023-01-28 21:38www.1681989.com免费网站
效果
HTML代码
XML/HTML Code复制内容到剪贴板
- <div class="box shadow"></div>
CSS代码
CSS Code复制内容到剪贴板
- .box {
- width: 300px;
- height: 100px;
- background: #c;
- border-radius: 10px;
- marg: 10px;
- }
- .shadow {
- position: relative;
- max-width: 270px;
- box-shadow: 0px 1px 4px rgba(0,0,0,0.3),/ 外阴影/
- 0px 0px 20px rgba(0,0,0,0.1) set;/内阴影/
- }
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-dex:-1;
- }
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-dex:-1;
- bottombottom:15px;
- left:10px;
- width:50%;
- height:20%;
- }
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-dex:-1;
- bottombottom:15px;
- left:10px;
- width:50%;
- height:20%;
- box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
- transform:rotate(-3deg);
- }
- .shadow::after{
- rightright:10px;
- left:auto;
- transform:rotate(3deg);
- }
伪元素before和after意思是在被选元素的内容前或后 插入内容