我需要将图像和 Bootstrap 轮播的标题居中对齐
我使用 php 代码显示来自数据库的随机图像
这是我用来保持宽高比的:
<div class="item">';
while ($resultados = $arte->fetch_assoc()) {
$title = utf8_encode($resultados['titulo']);
$id = $resultados['medidas'];
$tec = utf8_encode($resultados['tecnica']);
$img = $resultados['imagen'];
$home .= ' <img src="'.$img.'" style="background-size: cover;background-size: cover;width: auto;height: auto;min-width: 1%;max-height: 600px;max-width: 1000px;">
<div class="container">
<div class="carousel-caption">
<h1>'.$title.'.</h1>
<p class="lead">'.$id.'<br> '.$tec.'</p>
<a class="btn btn-large btn-inverse" href="/arte_objeto">Ver más</a>
</div>
</div>';
}
$home .= '</div>
这是结果:
所以也对齐标题,以便它在旋转木马的中心显示图像
我试过:
background-position: center center;
但是没用
最佳答案
在要居中的 div/图像上使用 margin:0 auto;
。
使用您的“检查元素”找到向左拉动的 div,然后应用该 css。
关于css - Bootstrap 轮播问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28493439/