[英]Is there a way in css to clear all font-family + font-size style declarations?
I have a page which is a cms/wysiwyg/ms word nightmare. 我有一个页面,这是一个cms / wysiwyg / ms字噩梦。
It pulls many paragraphs of text from a database, some of which have retained ms word's bizarre html tags - including font declarations!!! 它从数据库中提取了许多段落的文本,其中一些保留了ms word的奇怪的html标签 - 包括字体声明! ahh!
啊!
In one sentence I can have things like: 在一句话中我可以有这样的事情:
<span style="font-family:Verdana">this is some</span>
<span style="font-family:arial">ugly text!</span>
I was wondering if there is a way of removing all font-family and font-size styles so they will adapt the master stylesheet css? 我想知道是否有一种方法可以删除所有font-family和font-size样式,以便它们适应主样式表css?
I'd prefer to not get into massive preg_replace conditions if I can avoid it. 如果我可以避免它,我宁愿不进入大规模的preg_replace条件。 Thanks
谢谢
CSS: CSS:
span {
font-family: initial !important;
font-size: initial !important;
}
Well, if you're getting inline styles in many places, I would add this to the body CSS 好吧,如果你在许多地方获得内联样式,我会将它添加到body CSS中
body {
font-family: Arial, Helvetica, sans-serif !important;
font-size: 16px !important;
}
If you notice that all of the inline font styling are going on span
s, you could target spans instead of the body. 如果您注意到所有内联字体样式都在
span
s,那么您可以定位跨度而不是正文。
I chose these two fonts because they are the "default" fonts for Windows and Mac/iOS. 我选择了这两种字体,因为它们是Windows和Mac / iOS的“默认”字体。 Of course you can choose your own font size.
当然,您可以选择自己的字体大小。 The only unfortunate part about this is if you want a different font and font size in other places you'll have to use more
!important
s. 唯一不幸的是,如果你想在其他地方使用不同的字体和字体大小,你将不得不使用更多
!important
s。
You can use the !important
rule for this. 您可以使用
!important
规则。 But you will have to explicitly define each element you want it to go on (or use the universal selector *
) 但是你必须明确定义你希望它继续运行的每个元素(或使用通用选择器
*
)
http://jsfiddle.net/b8RKm/ http://jsfiddle.net/b8RKm/
* { font-family: Tahoma, sans-serif !important; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.