2014-01-31 69 views
0

我有一个问题,是否有可能做一些像纯CSS附件中的东西?CSS两个边框。不同的高度

<h3 style="border-bottom:1px solid #515151"><span style="border-bottom:3px solid #0066b3">HEADER</span></h3> 

回答

0

你可以这样说:

h3 { 
    height:14px; 
    padding-bottom: 10px; 
    width: 100%; 
    margin: 20px auto; 
    float: left; 
    border-bottom: 1px solid black; 
} 

h3 > span { 
border-bottom: 5px solid blue; 
} 

,并将HTML

<h3><span>HEADER</span></h3> 

Fiddle

+0

'h3 {padding-bottom:4px; border-bottom:1px solid#515151; } h3> span { border-bottom:5px solid#0066b3; }'这够了吗?我看在IE浏览器,FF,铬和它确定:) – jachu

+0

@jachu显然是的:p – Beterraba

0

为您具体的例子这应该这样做:

<style type="text/css"> 
    h3{ 
    border-bottom:1px solid #515151 
    } 
    span{ 
    border-bottom:3px solid #0066b3 
    } 
</style> 

但是,对于一个真正的使用,你可能会想一些clases添加到您的HTML元素做的更具体的目标css

0

你可以做到这一点,没有任何额外的标记。例如,通过使用伪元素。像这样:

h2 { 
    border-bottom: 1px solid grey; 
    position: relative; 
} 

h2:before { 
    height: 3px; 
    width: 70px; 
    background: blue; 
    border-radius: 3px; 
    position: absolute; 
    left: 0; 
    bottom: -2px; 
    content: ''; 
} 

见在线:http://jsfiddle.net/46uqV/

+0

问题是如果文本更改,他将不得不调整宽度。 – Beterraba

+0

@Beterraba,是的,我同意。但屏幕上还不清楚它是否需要与短语相同... – skip405

+0

谢谢,但我不知道蓝条的宽度。栏宽应与文本成比例。 – jachu

0

http://jsfiddle.net/2D8c9/

<span class="outer"> 
    <span class="inner"></span> 
    <span class="thinner-inner"></span> 
</span> 


.outer { 
    position:relative; 
    display:block; 
    width:200px; 
    height:20px; 
    background-color:black; 

} 
.inner { 
    position:absolute; 
    display:inline-block; 
    top:5px; 
    height:8px; 
    width:50%; 
    background-color:blue; 
    z-index:2; 
} 
.thinner-inner { 
    position:absolute; 
    top:8px; 
    display:inline-block; 
    width:100%; 
    background-color:red; 
    height:1px; 
    z-index:1; 
}