我正在使用自举程序制作转盘,但无法使图像响应。问题是高度远大于宽度的图像?我测试了另一幅较大的图像,该图像失真了。
body {
padding-top: 68px !important;
background-color: black;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Teste</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
</head>
<body>
<nav class="navbar navbar-expand-md fixed-top navbar-dark">
<div class="container">
<a href="index.html" class="navbar-brand">
<img src="#" alt="Logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar-content">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link pr-5 nav-active" href="#">TESTE</a></li>
<li class="nav-item"><a class="nav-link pr-5" href="#">TESTE</a></li>
</ul>
</div>
</div>
</nav>
<header class="container-fluid p-0">
<div id="carouselBanner" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<a href="top-movie.html"><img class="d-block w-100" src="https://image.tmdb.org/t/p/w600_and_h900_bestv2/rPdtLWNsZmAtoZl9PK7S2wE3qiS.jpg" alt="Fight Club"></a>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://image.tmdb.org/t/p/w600_and_h900_bestv2/yE5d3BUhE8hCnkMUJOo1QDoOGNz.jpg" alt="House">
</div>
</div>
<a class="carousel-control-prev" href="#carouselBanner" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" ></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselBanner" data-slide="next">
<span class="carousel-control-next-icon"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
旋转木马占据了图像的整个高度,我试图降低高度,但是图像失真了。
答案 0 :(得分:0)
我试图在您的CSS上添加一些样式,
<style>
body {
padding-top: 68px !important;
background-color: black;
}
.carousel-inner {
position: relative;
overflow: hidden;
}
.carousel-item {
position: relative;
width: 100vh;
height: 100vh;
display: none;
width: 100%;
}
.img {
height: 100%;
width: 100%;
background-repeat: no-repeat;
background-attachment: fixed !important;
background-size: cover !important;
background-position: center !important;
}
</style>
当我最小化它时,它会缩小