2015-05-22 23 views

回答

1

這是你想到的?

http://jsfiddle.net/j5gk9srn/

<div class="bar"></div> 

body { 
    background: #111; 
} 

.bar { 
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    margin: auto; 
    width: 10px; 
    height: 200px; 
    background-color: #aef; 
    -webkit-transform: rotate(45deg); 
     -ms-transform: rotate(45deg); 
      transform: rotate(45deg); 
} 
.bar:before, .bar:after { 
    position: absolute; 
    left: 0; 
    width: 0; 
    height: 0; 
    border-left: 5px solid transparent; 
    border-right: 5px solid transparent; 
    content: ''; 
} 
.bar:before { 
    top: -10px; 
    border-bottom: 10px solid #aef; 
} 
.bar:after { 
    bottom: -10px; 
    border-top: 10px solid #aef; 
} 
+0

感謝肖恩!這就是我想要的!我會在將來嘗試使用僞元素。那麼爲什麼要使用「內容:」;「?我們需要使用沒有內容來顯示形狀? – chenghuayang

+0

您需要爲前/後僞元素聲明內容。否則,在那裏沒有任何東西存在。 –

+0

感謝兄弟。我知道了! – chenghuayang

相關問題