久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

:hover:before text-decoration none 沒有效果?

:hover:before text-decoration none has no effects?(:hover:before text-decoration none 沒有效果?)
本文介紹了:hover:before text-decoration none 沒有效果?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

作為標題,我使用 .icon-* 添加圖標.向超鏈接添加圖標時:

As title, I'm adding icons using .icon-*. When adding an icon to an hyperlink:

<a href="#" class="icon-email icon-large">Email me!</a>

content 屬性插入的內容在懸停時顯示下劃線文本裝飾.我想只為之前的內容禁用 text-decoration:

The content inserted by content property shows the underline text-decoration on hover. I'd like to disable the text-decoration only for the content before:

[class^="icon-"]:before, [class*=" icon-"]:before {
    font-family: 'IcoMoon';
    font-style: normal;
    speak: none;
}
.icon-mail:before {
    content: "37";
}
[class^="icon-large-"]:before, [class*=" icon-large"]:before {
    font-size: 48px;
    line-height: 48px;
}
a[class^="icon-"]:before, a[class*=" icon-"]:before {
    margin-right: 5px;
    vertical-align: middle;
}

我試過了,但它不起作用(裝飾仍然可見):

I've tried this but it's not working (decoration is still visible):

a[class^="icon-"]:hover:before, a[class*=" icon-"]:hover:before {
    text-decoration: none;
    color: white;
}

推薦答案

作為 :before偽元素被渲染為其生成元素的后代框(更具體地說,就在第一個子內容框之前),它遵循 它的正常后代框對 text-decoration 的規則相同:

As the :before pseudo-element is rendered as a descendant box (more specifically, just before the first child content box) of its generating element, it obeys the same rules its normal descendant boxes do with respect to text-decoration:

后代元素的'text-decoration'屬性不能對祖先元素的裝飾產生任何影響.

The 'text-decoration' property on descendant elements cannot have any effect on the decoration of the ancestor.

有關詳細信息,請參閱這些答案:

See these answers for more details:

  • CSS text-decoration 屬性不能被子元素覆蓋
  • 我該怎么做讓這個 CSS 文本裝飾覆蓋工作?

沒有什么好辦法解決這個問題...唯一能立即想到的選擇是:

There isn't any good way around this... the only alternatives that come immediately to mind are:

  • 將文本包裝在其自己的 span 元素中,然后將 text-decoration 應用于該 span,如skip405所示.缺點當然是額外的標記.

  • Wrap the text in its own span element, then apply text-decoration to that span, as shown by skip405. The disadvantage is, of course, extra markup.

在您的 :before 偽元素中使用內嵌塊背景圖像而不是圖標字體中的內嵌文本(我還更正了與您的類選擇器的不一致):

Use an inline block background image instead of inline text in an icon font with your :before pseudo-element (I've also corrected the inconsistencies with your class selectors):

[class^="icon-"]:before, [class*=" icon-"]:before {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-size: contain;
    content: "";
}
.icon-email:before {
    background-image: url(icon-mail.svg);
    background-repeat: no-repeat;
}
.icon-large:before {
    width: 48px;
    height: 48px;
}
a[class^="icon-"]:before, a[class*=" icon-"]:before {
    margin-right: 5px;
    vertical-align: middle;
}

與 skip405 的解決方案相比,它的優勢在于您不必修改 HTML,但鑒于它使用 SVG 矢量背景圖片 和 background-size,在 IE8 中無法使用.

The advantage this has over skip405's solution is that you don't have to modify the HTML, but given that it uses SVG vector background images and background-size, it won't work in IE8.

如果您確實需要 IE8 支持,那么您必須回退到位圖圖像:

If you do need IE8 support, then you have to fall back to bitmap images:

.icon-email:before {
    background-image: url(icon-mail.png);
}
.icon-email.icon-large:before {
    background-image: url(icon-mail-large.png);
}

這篇關于:hover:before text-decoration none 沒有效果?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is CSS faster when you are specific?(當您特定時,CSS 會更快嗎?)
CSS sibling selectors (select all siblings)(CSS 兄弟選擇器(選擇所有兄弟))
IE: nth-child() using odd/even isn#39;t working(IE:使用奇數/偶數的 nth-child() 不起作用)
How can I tell if an element is in a shadow DOM?(如何判斷一個元素是否在影子 DOM 中?)
Can I use CSS to add a bullet point to any element?(我可以使用 CSS 為任何元素添加項目符號嗎?)
CSS attribute selector for non-empty attributes(非空屬性的 CSS 屬性選擇器)
主站蜘蛛池模板: 久久久久精| 在线视频国产一区 | 麻豆av在线免费观看 | 日韩中文在线视频 | 亚洲最大av网站 | 久草综合在线视频 | 91欧美精品成人综合在线观看 | 波多野结衣二区 | 日日操夜夜操天天操 | 欧美日韩在线精品 | 国产成人精品999在线观看 | 伦理片97 | 亚洲综合色丁香婷婷六月图片 | 国产日韩精品在线 | 精品国产欧美一区二区 | 天堂av影院 | 日韩一级精品视频在线观看 | 亚洲视屏 | 亚洲精品电影在线观看 | 欧美精品久久久 | 欧美精选一区二区 | 亚洲欧美在线观看 | 日韩精品一区二区三区在线观看 | 精品久久久久久亚洲综合网 | 久久久蜜桃一区二区人 | 男女视频在线观看网站 | 浴室洗澡偷拍一区二区 | av一级在线观看 | 亚洲在线一区 | 亚洲人成在线播放 | 盗摄精品av一区二区三区 | 午夜精品一区二区三区三上悠亚 | 午夜不卡福利视频 | 国产视频一区二区 | 国产在线精品一区二区三区 | 亚洲一区二区三区在线 | av天天爽 | 亚洲第一视频 | 久草中文在线观看 | 久久国产精品久久久久久 | 草草草久久久 |