dre*_*att 4 html css twitter-bootstrap twitter-bootstrap-3
当浏览器窗口调整大小时,如何让这些图像上的标题文本移动?我的实现是jicky,我需要一种方法来防止文本在调整窗口大小时滑动.
<div class="row">
<div class="col-md-6">
<img src="http://placekitten.com/600/375" class="img-responsive" />
<h2 class="homeImageLink">
<span>Caption Text</span>
</h2>
</div>
<div class="col-md-6">
<img src="http://placekitten.com/600/375" class="img-responsive" />
<h2 class="homeImageLink">
<span>Caption Text</span>
</h2>
</div>
</div>
.homeImageLink {
position: absolute;
top: 110px;
left: 0;
text-align: center;
width: 100%;
}
.homeImageLink span {
color: red;
font-weight: 300;
font-style: italic;
text-transform: uppercase;
letter-spacing: 15px;
pointer-events: none;
}
Run Code Online (Sandbox Code Playgroud)
Rah*_*til 15
只需将一个类添加到父容器中,使其位置相对.
.img-container {
position:relative;
}
Run Code Online (Sandbox Code Playgroud)
然后使homeImageLink绝对并在45%左右达到顶峰..
它会使它垂直居中..
.homeImageLink {
position: absolute;
top: calc(50% - 24px); //24px is font size of H1 I assume
left: 0;
text-align: center;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
在这里演示:http://codepen.io/anon/pen/bJadE
| 归档时间: |
|
| 查看次数: |
18349 次 |
| 最近记录: |