use*_*620 1 css carousel twitter-bootstrap
我在我的页面上实现了一个Bootstrap轮播,由于某种原因,我无法根据Web浏览器的大小重新定位标题文本.
这是我的HTML代码:
<!-- =======================CAROUSEL=========================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="img/main-banner.png" alt="First slide">
<div class="container">
<div class="carousel-caption">
<h1>Democratizing the Internet of Things!</h1>
<p><a class="btn btn-lg btn-primary" href="./index.php?d=splash" role="button">Try Splash</a></p>
</div>
</div>
</div>
<div class="item">
<img class="second-slide" src="img/banner-2.png" alt="Second slide">
<div class="container">
<div class="carousel-caption">
<h1>Another Heading!</h1>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在使用Bootstrap CDN:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
Run Code Online (Sandbox Code Playgroud)
这些都是我对旋转木马所做的CSS更改:
.carousel-caption {
position: relative !important;
width: 550px;
top: 210px;
left: 380px !important;
z-index: 600;
max-height:177px;
}
.carousel-caption h1 {
font-family: sans-serif !important;
font-size: 44px !important;
font-weight: 700 !important;
line-height:36px !important;
color: #444 !important;
margin: 0px !important;
padding: 0px !important;
text-shadow: 0px 0px 4px #fff !important;
text-align: left !important;
}
.carousel-caption p {
margin-top: 11px !important;
font-size:18px !important;
line-height:21px !important;
color:#333 !important;
padding-bottom: 11px !important;
margin-bottom: 11px !important;
text-shadow: 0px 0px 4px #fff !important;
text-align: left !important;
}
.carousel-control.left, .carousel-control.right {
background-image: none !important;
}
.carousel-indicators {
left: 405px !important;
}
Run Code Online (Sandbox Code Playgroud)
这是旋转木马全屏显示的内容:

以下是我开始更改Web浏览器大小时发生的情况:

我尝试过所有不同类型的职位,但对于我的生活无法弄清楚我做错了什么.任何帮助表示赞赏!
要在中心垂直对齐标题,我使用了CSS函数translateY或属性transform.
我还希望将标题直接放在左侧的旋转木马控件旁边.
我还删除了默认引导程序CSS添加的额外底部空间.
.carousel-caption {
width: 550px;
left: 15%;
top: 50% !important;
transform: translateY(-50%);
text-align: left;
bottom: initial;
}
Run Code Online (Sandbox Code Playgroud)
无论屏幕大小如何,标题现在都显示正确:
