【发布时间】:2020-02-28 03:05:42
【问题描述】:
我正在使用bootstrap4 构建一个简单的网站,并且我正在尝试将轮播设置为背景。有没有没有关键帧的简单方法?
【问题讨论】:
标签: php html css bootstrap-4 carousel
我正在使用bootstrap4 构建一个简单的网站,并且我正在尝试将轮播设置为背景。有没有没有关键帧的简单方法?
【问题讨论】:
标签: php html css bootstrap-4 carousel
您可以使用引导默认轮播并进行一些调整,即 z-index 和 position 属性。
图片1、2、3必须换成你自己的图片,没有它们就不行而且尺寸适合你的需要,你还可以为图片和箭头添加指示符循环浏览图像。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Carousel Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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>
<style>
/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 100%;
}
#demo{
position: absolute;
z-index: -1;
}
#frontpage{
color: red;
font-size: larger;
background-color: yellow;
opacity: 0.5;
padding: 50px;
}
</style>
</head>
<body>
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="Image1.jpg" alt="Image1" width="1920" height="1080">
</div>
<div class="carousel-item">
<img src="Image2.jpg" alt="Image2" width="1920" height="1080">
</div>
<div class="carousel-item">
<img src="Image3.jpg" alt="Image3" width="1920" height="1080">
</div>
</div>
</div>
<div id="frontpage">
My frontpage over the carousel
</div>
</body>
</html>
【讨论】:
carousel-inner img的宽度和高度,并调整图像的宽度和高度。
.carousel-inner img { width: 1500px; height: 1000px; }。您现在必须根据需要对其进行调整,并且可以编辑图像以使其不变形。