Html 更改 <ul> 中的字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8499114/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:59:16  来源:igfitidea点击:

Changing the font in an <ul>

htmlcss

提问by user502019

I am new to CSS and I am having trouble understanding how to control different elements with my stylesheet classes and id's. I am trying to use an <ul>for the footer links, for my website and I want to change the font of the links. Where and how do I apply this? No matter where I apply 'font-family: whatever', nothing changes.

我是 CSS 新手,无法理解如何使用样式表类和 id 控制不同的元素。我正在尝试将<ul>用于页脚链接,用于我的网站,并且我想更改链接的字体。我在哪里以及如何应用它?无论我在哪里应用“font-family:whatever”,都没有任何变化。

here is my CSS for the ul

这是我的 ul 的 CSS

#footer {
height: 50px;
width: 600px;
margin-left: auto;
margin-right: auto;
text-align: center;
}

#footer ul {
list-style-type: none;
color: #FFFFFF;
font-size: 16px;

}

#footer  li {
display: inline;

}

#footer  a:link {
color: #FFFFFF;
font-size: 16px;
text-decoration: none;
}

#footer a:visited {
color: #FFFFFF;
font-size: 16px;
text-decoration: none;
}

here is the html

这是html

<div id="footer">
<ul>
<li><a href="#"> About </a></li> |
<li><a href="#"> Contact </a></li> |
<li><a href="#"> Terms </a></li> |
<li><a href="#"> Blog </a></li>
</ul>
</div>

Also, how do I change the font for my divider between links | ?

另外,如何更改链接之间分隔符的字体 | ?

回答by gilly3

You are currently using font: Helvetica;. If you change that to font-family: Helvetica;it works:

您目前正在使用font: Helvetica;. 如果您将font-family: Helvetica;其更改为有效:

http://jsfiddle.net/6g8Km/

http://jsfiddle.net/6g8Km/

Edit:Well, you didhave font: Helvetica, before your edit.

编辑:嗯,在你编辑之前,你确实font: Helvetica

To style the pipes differently from the links, set font-familyon #footer lito the font you want for the pipes. Then set font-familyon #footer li a:linkto the font you want for the links.

并从链接中,设置不同风格的管道font-family#footer li与要使用管道中的字体。然后设置font-family#footer li a:link您要为链接的字体。

#footer  li { 
    font-family: serif;
} 
#footer li a:link { 
    font-family: sans-serif;
} 

回答by Aaron

#footer li a {
    font-family: Arial, Verdana, sans-serif;
}

Also, enclose your pipe characters in <span class="pipe">|</span, then apply a font-familyto span.pipe.

另外,将管道字符括在 中<span class="pipe">|</span,然后将 a 应用font-familyspan.pipe

回答by Fabián Heredia Montiel

You would put it in the li selector, in your list-item. Additionally, similar to divs, you have spans for small text segments you want to apply specific styling to.

您可以将它放在 li 选择器中,在您的列表项中。此外,与 div 类似,您有要应用特定样式的小文本段的跨度。

<span>|</span>
span { font-family: Arial, sans-serif; }

For instance.

例如。

回答by Dhamu

#footer ul
{ 
    padding:30px;
}
#footer ul li
{
    font-size:12px;
    list-style:disc;
}
#footer ul li a or #footer li a
{
    color:#333;
}
/*for links inside li*/

Just, but the element html name or class with in parent class or id in page. Enjoy with styles! Also keep rocking with css3!

只是,但是元素 html 名称或类在父类或页面中的 id 中。享受风格!还要继续使用 css3!