简体   繁体   English

在线下创建hr径向渐变

[英]Create a hr radial-gradient below the line

There is a wonderful hr gradient here in the answer (the jsfiddle he links to shows an updated css) - Create a beautiful horizontal line with CSS only . 答案中有一个很棒的hr梯度(他链接到的jsfiddle显示了一个更新的CSS)- 仅使用CSS创建漂亮的水平线 It is exactly what I am after but I would like the gradient to appear below then line instead of above it. 正是我所追求的,但是我希望渐变出现在然后在线条以下而不是在线条上方。

The html is very simple - HTML非常简单-

 hr.fancy-line { border: 0; height: 1px; position: relative; margin: 0.5em 0; /* Keep other elements away from pseudo elements*/ } hr.fancy-line:before { top: -0.5em; height: 1em; } hr.fancy-line:after { content: ''; height: 0.5em; /* half the height of :before */ top: 1px; /* height of hr*/ } hr.fancy-line:before, hr.fancy-line:after { content: ''; position: absolute; width: 100%; } hr.fancy-line, hr.fancy-line:before { background: -moz-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -webkit-gradient(radial, center center, 0px, center center, 75%, color-stop(0%, rgba(0, 0, 0, 0.1)), color-stop(75%, rgba(0, 0, 0, 0))); background: -webkit-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -o-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -ms-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); } body, hr.fancy-line:after { background: #f4f4f4; } 
 <hr class="fancy-line"></hr> 

I have tried various different things but cannot get it to work, plus whenever I change it, the line itself disappears. 我尝试了各种不同的方法,但是无法使其正常工作,而且每当我对其进行更改时,该行本身就会消失。

Please can someone help... thank you 请有人帮忙...谢谢

hr.fancy-line:after {
    content:'';
    height: 0.5em;   
    top: -8px;  /*change or bottom:0; */
}

 hr.fancy-line { border: 0; height: 1px; position: relative; margin: 0.5em 0; } hr.fancy-line:before { top: -0.5em; height: 1em; } hr.fancy-line:after { content: ''; height: 0.5em; top: -8px; /*or bottom:0; */ } hr.fancy-line:before, hr.fancy-line:after { content: ''; position: absolute; width: 100%; } hr.fancy-line, hr.fancy-line:before { background: -moz-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -webkit-gradient(radial, center center, 0px, center center, 75%, color-stop(0%, rgba(0, 0, 0, 0.1)), color-stop(75%, rgba(0, 0, 0, 0))); background: -webkit-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -o-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: -ms-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 75%); } body, hr.fancy-line:after { background: #f4f4f4; } 
 <hr class="fancy-line"></hr> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM