2012-07-10 82 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; 
}