简体   繁体   English

内部 CSS 有效,但外部 CSS 无效

[英]Internal CSS works, but external doesn't

Internal CSS works, but external doesn't.内部 CSS 有效,但外部 CSS 无效。 I've tried the external with the code !important, but it just didn't made any sense.我已经用代码 !important 尝试了外部,但它没有任何意义。 I want to add a gallery to my site.我想在我的网站上添加一个画廊。 But I have a problem.但我有一个问题。 As I've seen in the browser some margin overwrites the ext.正如我在浏览器中看到的,一些边距会覆盖 ext。 CSS. CSS。 But here's the thing, I have no margins in the HTML code.但事情就是这样,我在 HTML 代码中没有边距。 The only thing I can imagine is that the Bootstrap is doing something with high priority.我唯一能想象的是 Bootstrap 正在做一些具有高优先级的事情。

 div.gallery { margin: 5px; border: 1px solid #ccc; width: 180px; position: static; } div.gallery:hover { border: 1px solid #777; } div.gallery img { width: 100%; height: auto; } div.desc { padding: 15px; text-align: center; }
 <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <div class="gallery"> <a target="_blank" href="gtrr35.jpg"> <img src="gtrr35.jpg" alt="Nissan GT-R R35 Nismo"> </a> <div class="desc">Nissan GT-R R35 Nismo</div> </div>

Where is your custom css stylesheet linked?您的自定义 css 样式表链接在哪里? It should be the last of all the other tags (fromm top-left to bottom -right), otherwise it gets overwritten due the cascading aspect of CSS...它应该是所有其他标签的最后一个(从左上角到右下角),否则它会由于 CSS 的级联方面而被覆盖......

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

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