我已經開始爲我的項目使用滑塊滑塊。 我想在滑塊上添加一個h1標籤。我通過創建一個h1標籤,然後給它一個絕對位置來實現這一點。但是現在文本出現在滑塊後面。 繼承人我的代碼:H1滑塊後面的標籤
.centered {
text-align: center;
position: absolute;
}
.slick-slide{
width: 100%;
height: 100vh!important;
}
img {
width: 100%;
height:100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<!--general stuff -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no">
<!-- custom css-->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!--custom css-->
<link href="css/custom.css" rel="stylesheet">
<!--slider-->
<link rel="stylesheet" type="text/css" href="slider/slick/slick.css"/>
<link rel="stylesheet" type="text/css" href="slider/slick/slick-theme.css"/>
</head>
<body>
<div class="slider-section">
<h1 class ="centered">test</h1>
<!--slider -->
<div class="your-class">
<div><img src="https://dailypost.files.wordpress.com/2016/06/city.jpeg?w=1200"></div>
<div><img src="https://dailypost.files.wordpress.com/2016/06/city.jpeg?w=1200"></div>
<div><img src="https://dailypost.files.wordpress.com/2016/06/city.jpeg?w=1200"></div>
</div>
</div>
<!--jQuery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap js -->
<script src="js/bootstrap.min.js"></script>
<!--slick slider-->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="slider/slick/slick.min.js"></script>
<!-- custom js -->
<script src="js/custom.js"></script>
</body>
</html>
您可以找到現場演示這裏:
我想:
.centered {
text-align: center;
position: absolute;
z-index: 1000;
}
的z-index
添加這個CSS .centered {z-index的:10;} –