2014-09-12 168 views

回答

1

有很多方法可以實現這一點;你可以簡單地use a forward-slash as the content of a pseudo element。這會比使用轉換/傾斜的選項更進一步。

<span>Item One</span><span>Item Two</span> 
span:after { 
    content: "/"; 
    font-size: 5em; 
    vertical-align: middle; 
} 

span:last-child:after { 
    content: none; 
} 

的另一種方法,如我在前面段落中提到的,是skew a pseudo element

span::after { 
    content: ""; 
    margin: 0 1em; 
    background: black; 
    display: inline-block; 
    vertical-align: middle; 
    transform: skewX(-20deg); 
    width: .5em; height: 5em; 
} 

span:last-child::after { 
    content: none; 
} 

需要注意的是與僞元素打交道時,請記住,Internet Explorer 8中支持他們,但只能與一個:前綴是非常重要的。直到Internet Explorer 9,您纔可以將它們與::一起使用。

+1

這是一個非常有趣的方式來'視覺上'使用固定寬度和高度的':after'添加div並旋轉它。我從你的回答中學到了很多東西! :) – 2014-09-12 17:16:46

0

你可以用一個div給它的一邊border然後用-webkit-transformrotate它。

<div class="background"> 
</div> 
<div><label>Some Text Here</label></div> 
<div id="dv"> 
<label>Some Different Text Here</label> 
</div> 

CSS

.background { 
border-top: 3px solid #ccc; 
padding: 0; 
margin: 0; 
height: 50px; 
-webkit-transform: translateY(-20px) 
translateX(5px) 
rotate(330deg); 
} 
#dv 
{ 
-webkit-transform: translateY(-30px) translateX(300px) rotate(-1deg); 
} 

這裏的DEMO