html - 移动 View 中的文本重叠

标签 html twitter-bootstrap css twitter-bootstrap-3

这适用于更大的屏幕并显示我想要的方式,但在移动设备上,“右标题”与“左标题”重叠。左边的标题应该在上面,但右边的标题应该在它下面,但是它在左边的标题上面。

我该怎么办?

    <div class="IdeathonCover">
       <img class="img-responsive" width="100%" src="bg-image.jpg">
            <div class="IdeathonLeftTitle">
                <h1>Left Title</h1>
            </div>
            <div class="IdeathonRightTitle">
                <h1>Right Title</h1>
            </div>
    </div>

我也使用 bootstrap 3 布局尝试过这种方法,但它没有用。 “col-x-12”未被遵守:

    <div class="IdeathonCover">
       <img class="img-responsive" width="100%" src="bgimage.jpg">
           <div class="row">
               <div class="col-md-6 col-xs-12">
                   <div class="IdeathonLeftTitle">
                       <h1>Left Title</h1>
                   </div>
               </div>
               <div class="col-md-6 col-xs-12">
                    <div class="IdeathonRightTitle">
                       <h1>Right Title</h1>
                    </div>
               </div>
           </div>
    </div>

使用的 CSS 如下:

    .IdeathonCover {
        position: relative;
    }
    .IdeathonLeftTitle {
        position:absolute;
        bottom: 10%;
        left: 0;
        padding: 0px 50px 20px;
        color: #fff;
        font-weight: 300;
    }
    .IdeathonRightTitle {
        position:absolute;
        bottom: 10%;
        right: 0;
        padding: 0px 50px 20px;
        color: #fff;
        font-weight: 300;
    }

有人知道为什么会这样吗?!

最佳答案

如果您正在使用 Bootstrap,据我所知,在绝对定位元素中使用 Bootstrap 类没有任何问题。您可以尝试以下方法:

CSS:

.IdeathonCover {
    position: relative;
}
.IdeathonTitles {
    position: absolute;
    bottom: 10%;
    width: 100%;
}

还有你的 html:

<div class="container-fluid">
    <div class="row">
        <div class="IdeathonCover">
            <img class="img-responsive" src="bgimage.jpg" alt="">   
            <div class="IdeathonTitles">
                <div class="col-md-6">
                    <h1 class="text-center">Left title</h1>
                </div>
                <div class="col-md-6">
                    <h1 class="text-center">Right title</h1>
                </div>
            </div>
        </div>
    </div>
</div>

关于html - 移动 View 中的文本重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32137502/

相关文章:

javascript - 如何找到html元素的绝对坐标?

javascript - 删除 Firefox SDK 工具栏的关闭按钮

javascript bootstrap modal - 取消关闭

twitter-bootstrap - vue-clipboard2 在 bootstrap-vue 模态中不起作用

html - div 上的 clip-path 属性使 div 的 z-index 高于我的固定导航栏

javascript - Bootstrap 打开模态和超链接

javascript - Firefox 中索引数据库的无效状态错误

jquery - 更改展开和折叠的图标

javascript - 如何通过单击 100 个具有相同类别的框中的任何一个来打开模式?

javascript - 如何在 CSS 更改之间切换