0
A
回答
3
DEMO 1:
HTML:
<figure></figure>
CSS:
figure{
width:150px;
height:150px;
margin:50px auto;
background:#ccc;
position:relative;
box-shadow: 0 14px 0 -10px red;
}
figure:before, figure:after{
content:'';
position:absolute;
top: 2px;
width:0;
height:0;
}
figure:before{
left: -5px;
border-left: 5px solid transparent;
border-right: 0px solid transparent;
border-top: 77px solid red;
}
figure:after{
right: -5px;
border-left: 0px solid transparent;
border-right: 5px solid transparent;
border-top: 77px solid red;
}
DEMO 2
figure{
width:150px;
height:150px;
margin:50px auto;
background:#ccc;
position:relative;
box-shadow: 0 12px 0 -10px red;
}
figure:before{
content:'';
position:absolute;
top: -10px;
left: 0;
width:100%;
height:100%;
background:red;
z-index: -1;
-webkit-transform-style: preserve-3d;
-webkit-transform: perspective(800) rotateX(-40deg);
}
0
只需使用CSS3特性的情況下,可以通過一個僞元素和位置上施加transform
創建飛人的框後面如下:
.box {
width: 200px; /* Optional */
/* height: 150px; */ /* Optional */
position: relative;
}
.box:before {
content: "";
position: absolute;
background-color: lightgray;
top: -3%; bottom: -12%; left: 0; right: 0;
transform: perspective(50em) rotateX(-30deg);
z-index: -1;
}
因此陰影盒的尺寸將相對於盒子。但是,IE 9及以下版本不支持它。
相關問題
- 1. background-image:空中飛人CSS3
- 2. CSS3列與剪影
- 3. CSS3餅圖影子問題
- 4. 與陰影CSS3箭頭
- 5. CSS3的盒子陰影問題
- 6. CSS3帶陰影的3D盒子
- 7. CSS3盒子陰影沒有深度
- 8. CSS3盒子陰影在一邊
- 9. css3邊框和箱子陰影效果
- 10. CSS3陰影
- 11. CSS3框陰影
- 12. 使用CSS3盒子陰影的三面一個像素陰影
- 13. 雙面飛機上的陰影僞影
- 14. 減少內盒陰影與CSS3
- 15. CSS3「下拉陰影」與插圖爲png
- 16. 文字陰影效果與CSS3
- 17. CSS3黑色陰影
- 18. CSS3過渡影響
- 19. 投影下的CSS3空間
- 20. CSS3盒眼影+ JQuery的
- 21. CSS3箱子影子尺寸按百分比
- 22. CSS3使用子元素保留內部盒子陰影?
- 23. CSS3箱子影子大小 - 百分比單位?
- 24. 與影子分組的UITableView
- 25. css3 div將投影箱投影到textarea
- 26. CSS3插入/內部投影陰影嗎?
- 27. 帶邊框的飛人
- 28. 複製CSS3文字整理/飛在
- 29. CSS3框陰影和Bootstrap 3
- 30. Photoshop和CSS3背景陰影
只是想知道什麼樣的光線可以實現這個陰影。很酷的效果。 – nf071590 2014-09-05 19:12:49
看看我的答案,如果你需要更多的讓我知道。 – 2014-09-05 19:28:43