【发布时间】:2015-02-17 23:15:35
【问题描述】:
我想创建一个垂直和水平居中的白色悬停标题。围绕它,我想添加相同的填充/边距,并在一些填充/边距内,标题/标题居中,水平和垂直。
因为一切都是响应式的,我认为最好对大多数元素使用 %。也许缩略图/标题(html)的结构需要不同的写法,我现在有点卡住了。
在示例图像中,我添加了一些红色标记我的意思。
示例:
<div class="col-4">
<a class="thumb" href="#">
<img src="http://fakeimg.pl/500x330/ccc/">
<div class="caption"><span>Project title centered vertical and horizontal</span></div>
</a>
</div>
【问题讨论】:
-
也许How to center an element horizontally and vertically?这个问题可能会有所帮助。
-
感谢 Josh,看起来第一个选项不需要那么多代码。浏览器对变换的支持: translateX(-50%) translateY(-50%);够好吗?
标签: html css thumbnails caption