如何使用内联 css 更改标签的字体大小?

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

How to change font-size of a tag using inline css?

css

提问by Firdavs Kurbonov

Can't change font-size of a tag for given below code

无法更改以下代码的标签字体大小

<td valign="top" width="620"><strong><a href="images/pub/pub1.pdf" target="_self">Factsheet of the OSCE Border Management Staff College</a></strong><br /><br /><strong><span style="font-size: 11px; color: #aaaaaa;">14 June 2013</span></strong>

Tried:

尝试:

<td valign="top" width="620"><strong><a style="font-size:14px;" href="images/pub/pub1.pdf" target="_self">Factsheet of the OSCE Border Management Staff College</a></strong><br /><br /><strong><span style="font-size: 11px; color: #aaaaaa;">14 June 2013</span></strong>

Nothing changed;

没有改变;

<td valign="top" width="620"><strong><a class="pub" href="images/pub/pub1.pdf" target="_self">Factsheet of the OSCE Border Management Staff College</a></strong><br /><br /><strong><span style="font-size: 11px; color: #aaaaaa;">14 June 2013</span></strong>

a.pub
{
font-size: 14px;
}

No changes;

没有变化;

<td class="pub" valign="top" width="620"><strong><a  href="images/pub/pub1.pdf" target="_self">Factsheet of the OSCE Border Management Staff College</a></strong><br /><br /><strong><span style="font-size: 11px; color: #aaaaaa;">14 June 2013</span></strong>

td.pub
{
font-size: 14px;
}

No effects; It is using font of a tag from style.css file I want to change font-size for only this a tag. Any ideas what I am doing wrong?

无影响;它正在使用 style.css 文件中的标签字体,我只想更改此标签的字体大小。任何想法我做错了什么?

回答by Mr. Alien

Strange it doesn't change, as inline stylesare most specific, if style sheet has !importantdeclared, it wont over ride, try this and see

奇怪的是它不会改变,inline styles最具体的是,如果样式表已经!important声明,它不会越过,试试这个看看

<span style="font-size: 11px !important; color: #aaaaaa;">Hello</span>

回答by sangram parmar

use this attribute in style

在样式中使用此属性

font-size: 11px !important;//your font size

by !importantit override your css

通过!important它会覆盖你的 css

回答by Jukka K. Korpela

You should analyze your style.css file, possibly using Developer Tools in your favorite browser, to see which rule sets font size on the element in a manner that overrides the one in a styleattribute. Apparently, it has to be one using the !importantspecifier, which generally indicates poor logic and structure in styling.

您应该分析您的 style.css 文件,可能使用您喜欢的浏览器中的开发人员工具,以查看哪个规则以覆盖style属性中的方式设置元素上的字体大小。显然,它必须是使用说明!important符的一个,这通常表示样式中的逻辑和结构不佳。

Primarily, modify the style.css file so that it does not use !important. Failing this, add !importantto the rule in styleattribute. But you should aim at reducingthe use of !important, not increasing it.

首先,修改 style.css 文件,使其不使用!important. 如果失败,请添加!importantstyle属性中的规则。但是您应该致力于减少的使用!important,而不是增加它。