[英]How to Select specific CSS selectors from multiple stylesheets
I have 2 stylesheets -1.我有 2 个样式表 -1。 bootstrap 4.0 2. materialize 4.0引导程序 4.0 2. 物化 4.0
now I want to select specific selectors from both of these but how to override the same selected style from the other.现在我想从这两个选择器中选择特定的选择器,但如何从另一个覆盖相同的选定样式。
for example: I want to select the header navigation(navbar) style from bootstrap css but the navbar style in material is also activated at the same time and the output is garbage.例如:我想从bootstrap css中选择header navigation(navbar)样式但是material中的navbar样式也同时被激活并且输出是垃圾。 So how to disable the same selector from the other stylesheet.那么如何从其他样式表中禁用相同的选择器。
Thanks.谢谢。
Bootstrap and Materialize classes/markup are/is not same. Bootstrap 和 Materialize 类/标记是/不一样的。 What i mean is: In materialize for navbar
the markup is:我的意思是:在实现navbar
,标记是:
<nav>
<div class="nav-wrapper">
.....
<div/>
</nav>
while in Bootstrap:在 Bootstrap 中:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
...
</nav>
So for selecting a specific element it won't be that hard.Either use class name or tag name for accessing the elements.所以选择一个特定的元素不会那么难。使用类名或标签名来访问元素。
Firstly, one of the two stylesheets will overwrite the other anyway.首先,两个样式表中的一个无论如何都会覆盖另一个。 The stylesheet which is loaded last, overwrites all previously loaded stylesheets.最后加载的样式表会覆盖所有先前加载的样式表。 Example:例子:
Bootstrap: header { color: white; }
引导程序: header { color: white; }
header { color: white; }
Materialize: header { color: black; }
物化: header { color: black; }
header { color: black; }
If Materialize CSS is loaded last, it will overwrite the CSS of Bootstrap.如果最后加载 Materialize CSS,它将覆盖 Bootstrap 的 CSS。
In your case, you have to cover all attrubutes from both stylesheets, if you want to reach your goal.在你的情况下,如果你想达到你的目标,你必须涵盖两个样式表中的所有属性。 Example:例子:
Bootstrap: header { color: white; background: white; }
引导程序: header { color: white; background: white; }
header { color: white; background: white; }
Materialize: header { color: black; font-size: 14px; }
物化: header { color: black; font-size: 14px; }
header { color: black; font-size: 14px; }
Then you will have to modify all three used attibutes, to reach your goal:然后你将不得不修改所有三个使用的属性,以达到你的目标:
Custom CSS: header { color: blue; background: yellow; font-size: 20px; }
自定义 CSS: header { color: blue; background: yellow; font-size: 20px; }
header { color: blue; background: yellow; font-size: 20px; }
if you are going to call both CSS files, it might cause overlapping.如果您要调用这两个 CSS 文件,则可能会导致重叠。 and last called stylesheet will override the previous CSS styles.最后调用的样式表将覆盖之前的 CSS 样式。
Therefore the best and the easiest way is,因此,最好和最简单的方法是,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.