这篇文章主要介绍了CSS3实现翘边的阴影效果的代码示例,这里所谓的翘边的阴影就是指阴影分部不均而显得像是被翘起来的那种效果,需要的朋友可以参考下
效果:
2016613120844752.jpg
HTML代码:
XML/HTML Code复制内容到剪贴板
- <div class="box shadow"></div>
CSS代码:
CSS Code复制内容到剪贴板
- .box {
- width: 300px;
- height: 100px;
- background: #ccc;
- border-radius: 10px;
- margin: 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) inset;/*内阴影*/
- }
-
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-index:-1;
- }
-
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-index:-1;
- bottombottom:15px;
- left:10px;
- width:50%;
- height:20%;
- }
-
- .shadow::before,
- .shadow::after {
- content:"";
- position:absolute;
- z-index:-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意思是在被选元素的内容前或后 插入内容
|