css - 文本装饰在 DIV 中不起作用

标签 css html hyperlink text-decorations

我有以下 CSS:

.top-category-item  {
        height: 338px;
        background-color: black;
        position: relative;
        }

.top-category-item-copy {
        width: 100%;
        /* Fallback for web browsers that doesn't support RGBa */
        background: rgb(0, 0, 0);
        /*  RGBa with 0.8 opacity */
        background: rgba(0, 0, 0, 0.8);
        bottom: 0px;
        position: absolute;
        padding-left: 5px;
        padding-right: 15px;
        padding-top: 2px;
        padding-bottom: 4px;
        box-sizing:border-box;
        -moz-box-sizing:border-box; /* Firefox */
        -webkit-box-sizing:border-box; /* Safari */
        font-family: Georgia, Times New Roman, serif;
        font-size: 35px;
        line-height: 36px;
        font-weight: bold;
        color: #F1F1F1;
        }

.top-category-item-copy a       {
                text-decoration: none;
                }

这是我的 HTML:

    <a href="">
    <div class="top-category-item low-gutter">
    <img src="images/feature-placeholder.jpg" alt="latest-image-placeholder"/ width=100% height=100%>
    <div class="top-category-item-copy">Earlier French Quarter curfew for youths gets mixed reaction.</div>
    </div>
    </a>

我在 Stack Overflow 上搜索了此问题的解决方案:

  • 尝试稍微交换语法,例如.class-name a:link {text-decoration: none;}

  • 尝试声明一个全局a {text-decoration: none;},这可行,但感觉像是一种解决方法,而不是真正的解决方案

最佳答案

在 HTML 中,top-category-item-copy 是一个 div,以 a 作为父级。您的 CSS 表示“.top-category-item-copy 中的所有 a 标签没有文本装饰。”

关于css - 文本装饰在 DIV 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9469922/

相关文章:

css - 使用 CSS 的响应式列数表

Jquery 基于高度的 Truncate 解决方案?

internet-explorer-8 - PIE.htc 圆 Angular 在 IE8 中不起作用

html - 占位符中的 fontawesome 用户

javascript - 按类型或类而不是索引获取子节点

javascript - 如何将计数器变量从数字更改为字母?

seo - 图像和文本 DIV 作为 SEO 的内部链接

javascript - AngularJS ngShow 和焦点

php - 我怎样才能制作一个按钮链接,就像在 Facebook 中一样?

reactjs - React onClick 和 PreventDefault() 链接刷新/重定向?