2011-11-19 80 views

回答

3

你可以utilitize pseude元素:http://jsfiddle.net/XdHxS/4/

#flag { 
    width: 99px; 
    height: 50px; 
    text-align: center; 
    line-height: 50px; 
    border: 1px solid #bbb; 
    margin: 10px; 
    position: relative; 
    background: #fff; 
} 

#flag:before { 
    content: ""; 
    position: absolute; 
    left: 0; 
    bottom: 0; 
    top: 0; 
    background: #00f; 
    width: 33%; 
    z-index: 4; 
} 
#flag:after { 
    content: ""; 
    position: absolute; 
    right: 0; 
    bottom: 0; 
    top: 0; 
    background: #f00; 
    width: 33%; 
    z-index: 4; 
} 

#flag h1 { 
    position: relative; 
    font-size: 12px; 
    color: #999; 
    z-index: 16; 
} 
+0

完美的,很好的答案。 –

2

http://jsfiddle.net/XdHxS/3/

#flag { 
width: 99px; 
text-align: center; 
line-height: 25px; 
border-top: 25px solid blue; 
border-bottom: 25px solid red; 
margin: 10px; 
} 

#flag h1 { 
font-size: 12px; 
color: #999; 
display:block; 
height:25px; 
background-color:white; 
} 
+0

法国国旗的条纹是水平的,不像你的例子中的垂直 – Clive

+0

哈!你会想我会知道... –

+0

哈哈,你让我的一天。漂亮的边界黑客! –