2012-07-10 79 views
16

完全不知所措!我試着用幾種不同的方式重寫text-decoration: none。我也設法重新確定文字的大小,但text-decoration: none代碼不會。文字裝飾:無所謂

非常感謝。

代碼

.widget  
 
{ 
 
    height: 320px; 
 
    width: 220px; 
 
    background-color: #e6e6e6; 
 
    position: relative;        
 
    overflow: hidden;       
 
} 
 

 

 
.title  
 
{ 
 
    font-family: Georgia, Times New Roman, serif; 
 
    font-size: 12px; 
 
    color: #E6E6E6; 
 
    text-align: center; 
 
    letter-spacing: 1px; 
 
    text-transform: uppercase; 
 
    background-color: #4D4D4D;  
 
    position: absolute; 
 
    top: 0; 
 
    padding: 5px; 
 
    width: 100%; 
 
    margin-bottom: 1px; 
 
    height: 28px; 
 
    text-decoration: none; 
 
} 
 

 
a .title  
 
{ 
 
    text-decoration: none; 
 
}
<a href="#"> 
 
    <div class="widget"> 
 
     <div class="title">Underlined. Why?</div> 
 
    </div> 
 
</a>

+7

您的文本沒有爲我加下劃線。 – 2012-07-10 18:57:46

+0

你使用什麼瀏覽器? – jfrej 2012-07-10 18:57:59

+1

我與尼古拉,沒有強調。另外,發佈演示時請考慮整理您的空白空間;我們的目標是讓我們可以輕鬆地進行演示,查看和閱讀。此外,嵌套在「a」元素中的'div'在HTML5之外是無效的,因此在使用該構造時請確保您的文檔類型。 – 2012-07-10 18:58:04

回答

24

你有一個塊元素(DIV)內聯元素中(A)。這適用於HTML 5,但不適用於HTML 4.因此,也只有實際支持HTML 5的瀏覽器。

當瀏覽器遇到無效標記時,它們會嘗試修復它,但不同的瀏覽器會以不同的方式執行此操作,結果變化。某些瀏覽器會將塊元素移入內聯元素之外,有些瀏覽器會忽略它。

+0

啊,很好的解釋謝謝。 – 2012-07-10 19:02:34

-4

我只是做了舊的方式,我知道它不正確,但它是一個快速修復。

<h1><a href="#"><font color="#FFF">LINK</font></a></h1> 
+1

yukk! ''標籤 – 2014-03-25 04:13:15

+1

這是一個可憎的 – 2014-08-08 14:15:59

6

使用CSS Pseudo-classes,給你的標籤類,例如:

<a class="noDecoration" href="#"> 

,並添加到您的樣式表:

.noDecoration, a:link, a:visited { 
    text-decoration: none; 
} 
+0

這個答案不起作用 – 2014-08-21 06:30:04

3

試着將你的text-decoration: none;您:懸停的CSS 。

+0

這個答案不起作用 – 2014-08-21 06:29:02

1

我有一個答案:

<a href="#"> 
    <div class="widget"> 
     <div class="title" style="text-decoration: none;">Underlined. Why?</div> 
    </div> 
</a>​ 

它的工作原理。

21
a:link{ 
    text-decoration: none!important; 
} 

=>我:)工作,運氣好的話

+2

很酷,謝謝!順便說一句,當我需要強調懸停時,同樣的解決方案工作 - **。some_title:hover {text-decoration:underline!important; } ** – gnB 2015-06-18 03:50:23

+1

**令人難以置信的技巧謝謝** – Fattie 2017-04-13 03:26:31

0

我用下面的代碼來獲得礦山在Chrome中工作。您可以調整排料:

a:-webkit-any-link { color: black; } 
5

添加這種說法你的頭標記:

<style> 
a:link{ 
    text-decoration: none!important; 
    cursor: pointer; 
} 
</style> 
+0

完美的想法。謝謝:) – 2017-12-09 00:31:09

1

沒有下劃線即使我刪除了「文字修飾:無;」從你的代碼。 但我有類似的經歷。

然後我添加了一個代碼

a{ 
text-decoration: none; 
} 

a:hover{ 
text-decoration: none; 
} 

所以,試試你的代碼:懸停。

0

當我嘗試自定義WordPress主題和文本修飾對我沒有幫助時,我有很多頭痛的問題。 在我的情況下,我不得不刪除箱陰影。

a:hover { 
    text-decoration: none; 
    box-shadow: none; 
}