html - 为什么我的 bootstrap 列重叠?

标签 html css twitter-bootstrap

我正在制作一个单页布局的网站,其中每个部分都是全宽的,并且与视口(viewport)具有相同的高度。我使用 bootstrap 使这些部分中的内容响应,但是当我减小视口(viewport)大小时我的列重叠(而不是堆叠),我不知道为什么。

这是(部分)我的 css 和 html(希望它提供足够的信息来确定问题):

.contact {
	min-height: 100vh;
    background-color: rgb(225, 138, 64);
    position: relative;
}

#map  {
	height: 40vh;
	width: 80%;
	background: white;
	position: absolute;
	margin-top: 270px;
	margin-left: 20px;
	display: block;
}

.otherdiv {
    height: 40vh;
	width: 80%;
	background: white;
	position: absolute;
	margin-top: 270px;
	margin-left: 20px;
	display: block;
}

.maxWidth {
	max-width: 90%;
}
<div id="contact" class="contact">
	
	<div class="container maxWidth">
        <h1>Contact</h1>
        
        <div class="row">
            <div class="col-md-6">
                <p>Some text.</p>
                <div id="map"></div>
            </div>
            <div class="col-md-6">
                <div class="otherdiv"></div>
            </div>
        </div>
    </div>
	
</div>

最佳答案

您必须从您的 div id 和类中删除 position:absolute 属性。 如下,

#map  {
    height: 40vh;
    width: 80%;
    background: white;
    margin-top: 270px;
    margin-left: 20px;
    display: block;
}

.otherdiv {
    height: 40vh;
    width: 80%;
    background: white;  
    margin-top: 270px;
    margin-left: 20px;
    display: block;
}

继承人 CODEPEN示例。现在它已正确堆叠。

关于html - 为什么我的 bootstrap 列重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36535924/

相关文章:

javascript - 动态添加时模态弹出内容会溢出

jquery - href点击事件到。按钮点击事件。使困惑?

javascript - 从 angularjs 更改 Bootstrap 进度条宽度

jquery - 响应式导航选项卡,即可折叠的导航选项卡

javascript - 3 秒后切换 Img Source

html - Mozilla scale3d() 忽略 <SELECT> 元素

css - 关于在 css (Wordpress) 中设置导航栏选项卡样式的问题

html - 根据图像纵横比匹配按钮高度

javascript - 单击两次禁用折叠

html - <p> 中的文本在 IE/MS Edge 中部分隐藏在 Bootstrap 中