2013-03-18 75 views
4

我想用100%不透明度到0%的某种虚线渐变来强调我的链接。我做的应该是什么我像一个屏幕:带有不透明度梯度的虚线下划线链接样式

dotted links

我想做某事像

a { 
    border-bottom: 2px dotted #007acc; 
} 

但没有梯度为0,不透明度和单点之间的空间实在是太路小。

关于这个问题的另一个问题:我有一些:内容之前('+'),我不想让border-bottom打内容,就像你看到的。

这是甚至可能或我必须使用PNG背景吗?

jquery也可以。

+0

渐变边框WebKit中是可能的,我怀疑你将能够达到你想要使用帮助在这里什么HTTP:// CSS-技巧.com/examples/GradientBorder/ – Rockafella 2013-03-18 20:52:40

+0

感谢您的链接,这确实是曾经使用过的。 – sqe 2013-03-18 21:14:32

回答

4

下面是一个简单的例子。不知道它是否适合您的需求。

body{ 
    background:#111; 
} 
ul{ 
    padding:0; 
    margin:0; 
} 
li{ 
    margin-left:20px; 
    width:200px; 
    list-style:none; 
    border-bottom:dotted 2px #99f; 
    color:#99f; 
    position:relative; 
} 
li:before{ 
    content:'+'; 
    position:absolute; 
    left:-15px; 
} 
li:after{ 
    content:''; 
    position:absolute; 
    height:2px; 
    width:100%; 
    top:100%; 
    background:red; 
    left:0; 

background: -moz-linear-gradient(left, rgba(17,17,17,0) 0%, rgba(17,17,17,1) 100%); /* FF3.6+ */ 
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(17,17,17,0)), color-stop(100%,rgba(17,17,17,1))); /* Chrome,Safari4+ */ 
background: -webkit-linear-gradient(left, rgba(17,17,17,0) 0%,rgba(17,17,17,1) 100%); /* Chrome10+,Safari5.1+ */ 
background: -o-linear-gradient(left, rgba(17,17,17,0) 0%,rgba(17,17,17,1) 100%); /* Opera 11.10+ */ 
background: -ms-linear-gradient(left, rgba(17,17,17,0) 0%,rgba(17,17,17,1) 100%); /* IE10+ */ 
background: linear-gradient(to right, rgba(17,17,17,0) 0%,rgba(17,17,17,1) 100%); /* W3C */ 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00111111', endColorstr='#111111',GradientType=1); /* IE6-9 */ 
} 

http://jsfiddle.net/KZPbf/

便捷的跨浏览器的梯度发生器:http://www.colorzilla.com/gradient-editor/

+0

这是一个有趣的概念。 – 2013-03-18 20:58:58

+0

@VinnyFonseca我唯一能想到的就是除了生成一系列具有不同背景颜色的单个dom对象之外。 :) – Andy 2013-03-18 21:11:34

+0

谢谢,这就是我一直在寻找的!确实有趣的概念。 – sqe 2013-03-18 21:13:13

1

您可以使用具有线性渐变背景的psuedo元素重叠在边框的顶部。

a { 
    border-bottom: 2px dotted #007acc; 
} 
a:after { 
    content: ''; 
    display: block; 
    position: absolute; 
    width: 100%; 
    height: 2px; 
    top: 100%; 
    background: linear-gradient(left, rgba(22, 23, 25, 1) 0%, rgba(22, 23, 25, 0) 100%); 
} 

您的背景可能需要保持相同的颜色,但这应该可以完成这项工作。您仍然需要供应商前缀和正确的颜色代码,具体取决于您计划支持的浏览器。