简体   繁体   English

使用外部CSS样式表仅更改HTML的特定部分

[英]Alter with an external CSS Stylesheet only a specific part of the HTML

I have an html document. 我有一个html文件。

In the document I link an external CSS Stylesheet 在文档中,我链接了一个外部CSS样式表

<link rel="stylesheet" type="text/css" href="css/whatever.css" />

But this external CSS Stylesheet modifies all my HTML document. 但是,此外部CSS样式表修改了我的所有HTML文档。

I need the External CSS Stylesheet to modify only a specific section of the HTML document. 我需要外部CSS样式表仅修改HTML文档的特定部分。

You can define the css inside the html document in two differents ways. 您可以通过两种不同的方式在html文档中定义css。

<style> //Your style </style>

or inline <tag style:"property:style;"></tag> 或内联<tag style:"property:style;"></tag>

That's what classes are for if you want to style a specific part just wrap it in a div, give it a class and style it. 如果要对特定零件进行样式设置,只需将其包装在div中,给它一个类并为其设置样式,这就是类的用途。

 p { color: red; } .specific p { color: blue; } 
 <div class="specific"> <p>Test</p> </div> <p>Test</p> <p>Test</p> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM