0
A
回答
3
是否這樣?
.fancy-line {
border: 0;
height: 1px;
position: relative;
margin: 0.5em 0;
}
.fancy-line:before {
top: -0.5em;
height: 1em;
}
.fancy-line:after {
height: 0.5em;
top: calc(-0.5em + 1px); /* adjusted this */
}
.fancy-line:before, .fancy-line:after {
content: '';
position: absolute;
width: 100%;
}
.fancy-line, .fancy-line:before {
background: radial-gradient(ellipse at center, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 75%);
}
body, .fancy-line:after {
background: #f4f4f4;
}
-Some Text-
<div class="fancy-line"></div>
原始代碼產生徑向漸變並覆蓋它的底部一半用彩色一樣的背景的塊。根據您的要求調整它只是將覆蓋物從底部移動到頂部的問題。請注意:hr
元素必須自行關閉。這排除了使用:before
和:after
,因爲自閉元素不能有孩子。在參考答案中,他們沒有使用hr
的任何特殊功能,所以我在這裏將其轉換爲div
。
1
在此請看:http://jsfiddle.net/9rovqvoj/1/
它基本上是相同的,但加入僞元素之前口罩:之前不是:後添加的z-index它。
hr.fancy-line:after {
top: -0.5em;
height: 1em;
}
hr.fancy-line:before {
content: '';
height: 0.5em;
top: -0.5em;
z-index: 999;
}
+0
謝謝你的回答。不過,我更願意接受@Ouroborus的答案作爲解決方案,因爲它使用了正確的HTML代碼(並且它不使用z-index,這對我來說更像是一個CSS技巧,因爲陰影是由:元件)。 –
+0
這是在僞元素之前的z-index,我錯過了刪除行頂部顯示的陰影 –
相關問題
- 1. 如何陰影底部
- 2. 底部陰影到ListPopupWindow android
- 3. CollectionView底部的陰影
- 4. 添加陰影UINavigationBar的底部只有
- 5. UITableView陰影頂部和底部
- 6. 頂部和底部的盒子陰影
- 7. 從UIWebView刪除頂部/底部陰影?
- 8. 如何設置一個盒子陰影的div元素的所有方面,左陰影,右陰影,頂部陰影,底部陰影?
- 9. Createjs陰影只在右側和底部
- 10. 刪除div底部的方塊陰影?
- 11. JInternalFrame的底部陰影問題
- 12. 沒有在頂部或底部顯示框陰影
- 13. 應用底部框陰影在左側和右側底部留下一些陰影空間
- 14. 盒陰影的文本框只有底部
- 15. CSS虛線陰影
- 16. 使用頁腳的UITableView底部不需要的水平線
- 17. 在iText的頁面底部繪製一條水平線?
- 18. Android XML:水平居中在底部
- 19. ggplot2圖例底部和水平
- 20. Matplotlib極線與陰影線
- 21. 將陰影添加到UIImageView的頂部和底部
- 22. css嵌入框陰影頂部,左側,右側,底部圖像
- 23. ItextSharp平滑背景陰影
- 24. 根據因子水平的陰影ggplot2背景
- 25. 如何創建水平陰影分隔欄
- 26. 沒有陰影
- 27. 沒有陰影
- 28. 水平垂直只有線
- 29. PHPPresentation - 折線圖陰影
- 30. Mathematica,PDF曲線和陰影
顯示您嘗試過的代碼。 – Ouroborus