html - [html&css]为什么使用margin-top : -50px?背景色会消失

标签 html css twitter-bootstrap-3

<分区>

当我将“col-xs-12”类添加到id为“me”的div中时,它不会停留在中心;然后我删除类,div 到中心,但是一半的背景会消失,如何解决?

有代码:

<div class="container container-fluid">
    <div class="row text-center" style="margin-top: -50px;">

        <!--There is the div what I want to put at center.-->
        <div id="me" class="center-block clearfix col-xs-12" style="
            height: auto;
            width: 220px;
            background-color: #5B0707;
            padding: 10px;
            color: white">
            Text
        </div>
    </div>
</div>

第一个问题的拍摄:

enter image description here

第二个:

enter image description here

网址是:www.tengzeyuan.com

最佳答案

只需添加

position: relative;

id为me的div的样式

<div>会像

<div id="me" class="center-block clearfix col-xs-12" style="
     height: auto;
     position: relative;
     width: 220px;
     background-color: #5B0707;
     padding: 10px;
     color: white">
            Text
</div>

请看下面的截图

enter image description here

关于html - [html&css]为什么使用margin-top : -50px?背景色会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32360322/

相关文章:

css - 如何强制 Bootstrap 3 使用桌面菜单?

javascript - 为 H1 元素赋予随机颜色

html - 部分未显示在标题下

javascript - 使用 Javascript 播放和暂停图像

php - 360 度网格——以奇数条记录结束行

html - 在厚重的文本页面上,包装器不会到达页面的最底部

html - 粘性页脚中的 hr 问题

html - 我怎样才能把一个 body 分成五个相等的部分

html - 响应式导航栏元素

css - Bootstrap 3 : Moving columns in between