Html 文字装饰:没有不适用于 ul
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25092666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
text-decoration: none not working on ul
提问by Matt Lee
I've seen a lot of questions relating to this subject but none of them answered my question. I am making a sidebar for a site and I'm trying to make the links in boxes that are the same width as the sidebar, have just a little padding, maybe 10-15px and a tiny bit of space between each. Maybe 3px. But I can't seem to get text-decoration: none; to work no matter what I've tried.
我已经看到很多与此主题相关的问题,但没有一个回答我的问题。我正在为一个网站制作侧边栏,我正在尝试制作与侧边栏宽度相同的框内的链接,只有一点点填充,可能是 10-15 像素,每个框之间有一点点空间。也许3px。但我似乎无法获得 text-decoration: none; 无论我尝试过什么,都可以工作。
This is the most successful code I've gotten so far:
这是迄今为止我得到的最成功的代码:
HTML
HTML
<div id= "sidebar">
<h3>Navigation Links</h3>
<div id= "sidelinks">
<ul>
<li><a href= "#">Home</a></li>
<li><a href= "#">Biography</a></li>
</ul>
</div>
</div>
CSS
CSS
#sidebar {
background: #464646;
width: 250px;
height: 1000px;
margin-left: 50px;
border-radius: 15px;
}
h3 {
font-family: 'Coda', cursive;
color: white;
background: #6B6B6B;
font-size: 24px;
text-align: center;
padding: 15px 0 8px 0;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
#sidelinks {
font-family: 'Armata', sans-serif;
font-size: 25px;
text-decoration: none;
color: white;
background-color: #4D4D4D;
padding: 10px;
position: relative;
}
回答by GillesC
Removing the text-decoration
and setting the colour is easy
删除text-decoration
和设置颜色很容易
#sidelinks a {
color:black;
text-decoration:none;
}
So is removing the dots
删除点也是如此
#sidelinks ul {
list-style:none;
padding:0;
margin:0;
}
If you look at the CSS you posted none of it was actually targeting <a>
or <ul>
so not sure why you were expecting other style than the default ones.
如果你看一下你发布的 CSS,它实际上没有一个是针对的,<a>
或者<ul>
不知道为什么你期望其他样式而不是默认样式。
The fiddle doesn't have everything but it should send you in the right direction: http://jsfiddle.net/eNUpJ/
小提琴没有一切,但它应该向您发送正确的方向:http: //jsfiddle.net/eNUpJ/
回答by ShibinRagh
add it reset css , I think you have to learn about css reset http://meyerweb.com/eric/tools/css/reset/
添加它 reset css ,我想你必须了解 css reset http://meyerweb.com/eric/tools/css/reset/
a {text-decoration: none;}
or
或者
#sidelinks a {text-decoration: none;}