Following the solution from this SO Question, I put this in my own CSS:
#bootstrap-override .carousel.slide {
max-width: 1920px;
min-width: 900px;
overflow: hidden;
margin-left: auto;
margin-right: auto;
}
#bootstrap-override .carousel-inner {
width: 1920px;
left: 50%;
margin-left: -960px;
}
But... it doesn't work. Bootstrap 4's own CSS wins for some reason. Here's Bootstrap's CSS:
.carousel {
position: relative;
}
.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
}
.carousel-inner::after {
display: block;
clear: both;
content: "";
}
// the .slide class doesn't appear anywhere (I'm guessing it's just used by the JS, but I don't know that).
My CSS is defined after Bootstrap's, as well:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Condensed&display=swap">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="./css/index.css">
<title>...</title>
</head>
If I place my overriding CSS in the <head>
it works correctly (and I get why) but I don't understand why it isn't working when I specify an id+class in my own CSS. As I understand it (which, at this point, must be very wrong) my CSS should have won out over Bootstrap's CSS even without specifying the id. Anybody know what kind of Cascading-Style-Steroids Bootstrap is juicing with?
Edit: Adding in the relevant HTML, as requested.
<body id="bootstrap-override">
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<div class="carousel-inner" style="height: 100%;"">
<div class=" carousel-item active">
<img class="d-block" src="./res/image.png" alt="First slide">
<div class="carousel-caption d-none d-md-block">
<table style="margin-left:auto; margin-right:auto;">
<tr>
<td class="align-middle">
<img src="./res/logo.png" alt="...">
</td>
<td class="align-middle">
<h3>...</h3>
</td>
</tr>
</table>
</div>
</div>
<div class="carousel-item">Slide #2...</div>
<div class="carousel-item">Slide #3...</div>
</div>
</div>
</body>