简体   繁体   English

如何更改此 div 容器上的 css 样式

[英]How to change the css styling on this div-container

I want to overwrite a given styling template:我想覆盖给定的样式模板:

Based on this example: https://github.com/evilz/vscode-reveal/blob/master/views/logo.ejs基于这个例子: https://github.com/evilz/vscode-reveal/blob/master/views/logo.ejs

<div id="logo" style="position: fixed; top: 20px; left: 20px; z-index: 1">
    <img src="Logo.svg">
</div>

I've added a custom css form based on this sample: https://github.com/evilz/vscode-reveal/blob/master/libs/reveal.js/3.8.0/css/theme/blood.css我添加了基于此示例的自定义 css 表单: https://github.com/evilz/vscode-reveal/blob/master/libs/reveal.js/3.8.0/css/theme/blood2A217BAZ5F5C

#logo {
  position: fixed;
  top: 100px;
  transform: scale(2.5);
}

The custom theme is loaded, but i does not change the setting on the logo.自定义主题已加载,但我没有更改徽标上的设置。

The inline styles are interpreted as more important than the ones in the css file so to override them you need to use !important :内联 styles 被解释为比 css 文件中的更重要,因此要覆盖它们,您需要使用!important

#logo {
    position: fixed;
    top: 100px !important;
    width: 300px;
}

It would be better to remove the inline styles if you're allowed to do that.如果允许这样做,最好删除内联 styles。

It's because inline style on HTML takes priority over internal/embedded CSS.这是因为 HTML 上的内联样式优先于内部/嵌入式 CSS。 So what you can do is to overight the HTML (considered as a bad practice)所以你可以做的是过度使用 HTML (被认为是一种不好的做法)

<div id="logo" style="position: fixed; top: 100px; width: 300px; left: 20px; z-index: 1">
    <img src="Logo.svg">
</div>

or the best solution:或最佳解决方案:

<div id="logo">
    <img src="Logo.svg">
</div>
#logo {
    position: fixed;
    top: 100px;
    width: 300px;
}

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

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