我有以下 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/