2015-12-02 118 views
-2

如何在下面的圖像中使用CSS中的斜角下劃線?在CSS中使用斜角下劃線

enter image description here

謝謝你的任何形式的幫助。

+3

預計你至少嘗試爲自己的代碼這一點。堆棧溢出不是代碼寫入服務。我建議你做一些額外的研究,無論是通過谷歌或通過搜索,做一個嘗試和。如果您仍然遇到麻煩,請返回**您的代碼**並解釋您嘗試過的以及爲什麼它不起作用。 –

+1

你可以嘗試這樣的[小提琴](http://jsfiddle.net/mq5Lqate/) –

+0

我已經嘗試過,但我忘記了如何做的代碼和想法。抱歉!!! –

回答

3

你的意思是這樣的http://jsfiddle.net/060Lgxk8/

h1 { 
    font-size: 24px; 
    text-transform: uppercase; 
    font-weight: bold; 
    font-family: Arial; 
    display: inline-block; 
    padding: 0 5px 3px 0; 
    border-bottom: 3px solid #000; 
    margin: 0; 
    position: relative; 
} 
h1:after { 
    content: ""; 
    width: 15px; 
    height: 3px; 
    display: block; 
    background-color: #000; 
    position: absolute; 
    right: -13px; 
    bottom: 1px; 
    transform: rotate(-35deg); 
} 

嘗試閱讀本代碼,以便了解它是如何工作的。不過,這很簡單。

+0

非常感謝,夥計。這非常有幫助。我正在嘗試做,但我總是對如何使用之前和之後的混淆。 –

1

您可以使用:pseudo元素與borderskewx

* { 
 
    box-sizing: border-box; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
ul { 
 
    margin: 15px; 
 
} 
 
ul li { 
 
    display: inline-block; 
 
    padding: 10px; 
 
    margin: 5px; 
 
    position: relative; 
 
    text-align: center; 
 
    font-size: 18px; 
 
} 
 
ul li:before { 
 
    content: ''; 
 
    width: 100%; 
 
    height: 12px; 
 
    border-width: 2px; 
 
    border-style: solid; 
 
    border-color: transparent black black transparent; 
 
    position: absolute; 
 
    bottom: 0; 
 
    left: 0; 
 
    transform: skewX(-25deg); 
 
}
<ul> 
 
    <li>Home</li> 
 
    <li>Contact</li> 
 
</ul>

+0

我更喜歡這個,因爲它不需要任何複雜的定位並且可以響應。 – Harry

+0

謝謝@哈里:) –