Posted in HTML / CSS onJune 13, 2016
效果:
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意思是在被选元素的内容前或后 插入内容
CSS3实现翘边的阴影效果的代码示例
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@