【发布时间】:2016-02-05 07:39:38
【问题描述】:
所以我有一个引导行,其左侧的文本内容位于 4 列的 div 中,右侧的图像位于另一个 8 列的 div 中。现在,在基于平板电脑的视图中,我需要我的图像相对于其左侧的文本位于其容器的确切中心(可以添加新文本,因此图像相对于文本的中心对齐应该是动态的)
HTML:
<div class="row">
<div class="col-sm-8 col-sm-push-4 tab_image">
<img src="images/event/event-banner-v3.jpg" alt="">
</div>
<div class="col-sm-4 col-sm-pull-8 col-xs-12">
<p>This year's Bank of Scotland Great Scottish Run, will see thousands of runners to the streets of Glasgow on Sunday 4 October.<br><Br>Join us at the biggest running event in Scotland and soak up the atmosphere provided by thousands supporters lining the streets, music and bands on the run, charity cheering points..</p>
</div>
</div>
对于 CSS:我现在所做的是硬编码一个值,以确保它以上面的 p 标签为中心,但是当我添加新的 Lorem Ipsum 文本时,它没有居中。我需要的是当 p 标签中的文本发生变化时图像的动态居中。
CSS:
@media (min-width: 768px) and (max-width: 991px){
.tab_image {
position: relative;
transform: translateX(17%);
transform: translateY(17%);
}
【问题讨论】:
-
为什么你有两次
transform属性?我也很欣赏 jsFiddle 演示,也许是所需效果的图像
标签: html css twitter-bootstrap