html - 是否可以在 html 中加载外部 css "specific some lines"?

标签 html css

是否可以在 html 中加载外部 css “特定的一些行”
例如:我有一个带有一些 div 的页面,我希望页面从 css 加载仅特定的一些行,而不是整个 css,请参见下面的代码片段。有没有办法显示 div1 和div2 样式,而不是所有四个?

.class1 {
	background-color:#FC0;
	width:300px;
	height:50px;
}
.div1 {
	background-color:#CCC;
	width:300px;
	height:50px;
}
.class2 {
	background-color:#F00;
	width:300px;
	height:50px;
}
.div2 {
	background-color:#FFC;
	width:300px;
	height:50px;
}
<div class="class1">class1 text (I don't want this css)</div>
<div class="div1">div1 text</div>
<div class="class2">class2 text (I don't want this css)</div>
<div class="div2">div2 text</div>

最佳答案

将您的 css 文件分开,并仅链接到包含您需要的 css 的 css 文件。

关于html - 是否可以在 html 中加载外部 css "specific some lines"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46806589/

相关文章:

html - 在 Bootstrap 4 上更改下拉图标

php - 如果旧的 img 上传具有不同的扩展名,我如何用新的 img 上传覆盖它们

css - 在主页上获取图像电视 modx 革命

html - 导航子菜单 - 出现在左侧

javascript - 无法从 Angular 的下拉列表中填充和发布值

javascript - 如何更改点击时的图像链接

javascript - 从 Javascript 自动播放视频元素在 iOS Safari 上不起作用

javascript - 使用 CSS 样式化 Javascript

css - 将窗口调整为较小时,绝对位于右侧的 div 会超过左侧 div

html - Css:元素在 Firefox 上 float 在图像上,但在其他浏览器中没有。 firefox 是遵守 css 标准还是其他浏览器?