【发布时间】:2017-05-17 16:55:57
【问题描述】:
我可以将外部样式表仅链接到 HTML 文件的特定元素吗?
我试过了:
<div id="main">
<!-- I don't want to style .alert from the external css -->
<div class="alert alert-success" role="alert">I don't want to style this alert from the external css.</div>
<div id="preview">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Specific Content Start - I want to style only this element with bootstrap -->
<h1>Bootstrap 3 - Specific Content</h1>
<!-- Specific Content End -->
</div>
</div>
【问题讨论】:
-
不,你不能那样做。只需为要覆盖的元素编写更具体的选择器。
-
有没有 iframe 标签@ScottMarcus 的技巧或插件或解决方案?
-
@techLove 不,你没有。请不要提倡
!important,因为众所周知这是一种糟糕的技术。您只需要创建一个更具体的选择器。它可以是基于id的选择器或更接近元素的选择器。 -
但是引导样式仍然存在。
标签: html css twitter-bootstrap twitter-bootstrap-3 stylesheet-link-tag