我想制作一条如下所示的垂直线:
http://i41.tinypic.com/2na44n7.png
我尝试过以下代码:
div.vertical-line{
float:right;
width:5px;
background-color:black;
margin-right:20px;
background: #FFFFFF;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#FFFFFF), to(#CFCFCF));
background: -webkit-linear-gradient(#FFFFFF, #CFCFCF);
background: -moz-linear-gradient(#FFFFFF, #CFCFCF);
background: -ms-linear-gradient(#FFFFFF, #CFCFCF);
background: -o-linear-gradient(#FFFFFF, #CFCFCF);
background: linear-gradient(#FFFFFF, #CFCFCF);
-pie-background: linear-gradient(#FFFFFF, #CFCFCF);
behavior: url(/pie/PIE.htc);
}
但结果与预期不符。 这是结果: http://jsfiddle.net/rLyyc/
它很接近,但它不会在线的末端“淡出”。
有什么建议吗?
提前感谢!
答案 0 :(得分:2)
你想要添加另一个停止点,即
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#FFFFFF), to(#CFCFCF), to(#FFFFFF));
导致:
div.vertical-line{
float:right;
width:5px;
background-color:black;
margin-right:20px;
min-height: 550px;
height:100%;
background: #FFFFFF;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#FFFFFF), to(#CFCFCF), to(#FFFFFF));
background: -webkit-linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
background: -moz-linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
background: -ms-linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
background: -o-linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
background: linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
-pie-background: linear-gradient(#FFFFFF, #CFCFCF, #FFFFFF);
behavior: url(/pie/PIE.htc);
}
值得一看MDN,看看颜色停止在线性渐变中是如何工作的:https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
答案 1 :(得分:2)
使用this generator,我得到了这个:
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #c6cbd2 50%, #ffffff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(50%,#c6cbd2), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#c6cbd2 50%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#c6cbd2 50%,#ffffff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#c6cbd2 50%,#ffffff 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#c6cbd2 50%,#ffffff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
答案 2 :(得分:0)
这将创建您要查找的行并将其放置在页面中间。只需调整线条粗细的宽度,线条高度从上到下的高度,顶部线条在线条开始前的距离,以及颜色到您想要的颜色。
body:after {
content:"";
position: absolute;
z-index: 1;
top:50%;
bottom:0;
left:50%;
border: 0;
height: 80%;
width:1px;
background: #333;
background-image:
-webkit-linear-gradient(top, #ccc, #333, #ccc);
background-image: -moz-linear-gradient(top, #ccc, #333, #ccc);
background-image: -ms-linear-gradient(top, #ccc, #333, #ccc);
background-image: -o-linear-gradient(top, #ccc, #333, #ccc);
}