BootStrap网格无法正常工作?

时间:2017-03-26 23:25:39

标签: html css twitter-bootstrap grid

我正在这个网页上工作,到目前为止我花了大部分时间来完善动画,所以还没有任何内容,只有几个div。正如你在图片中看到的那样,我遇到的问题是包含短语Hello World的“row”div!不知何故,它落在包含灰色和橙色空白div的“行”之上。对于我的生活,我无法弄清楚为什么。我唯一能想到的可能是引导程序的链接有问题吗?所有代码和屏幕截图如下。在此先感谢您的帮助。

作为一个侧面问题,现在相当不重要,有人能告诉我为什么导航栏上方有一个小的白色间隙?

Link to screenshot of top 1/3rd of page and browser

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Timothy Sutterby">
<!-- <meta HTTP-EQUIV="refresh" CONTENT="10"> -->
<!-- The above 3 meta tags *must* come first in the head; any other head 
     content must come *after* these tags -->

<title>T G Sutterby</title>

<link rel="stylesheet"            href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/880f652677.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="CSS/TGSstyles.css">

</head>

<body>

<!-- Modals -->



<!-- End Modals -->

<!-- Nav Bar -->

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
</button>
    </div>
    <a class="navbar-brand" id="navbar-brand" href="#"><span id="brand-    span">Brand</span></a>
    <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-left">
            <li><a href="#">Left</a></li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">L Down <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">One more separated link</a></li>
                </ul>
            </li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"    role="button" aria-haspopup="true" aria-expanded="false">D Right <span    class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">One more separated link</a></li>
                </ul>
            </li>
            <li><a href="#contact">Right</a></li>
        </ul>
    </div>
</nav>

<!-- End Nav Bar -->

<!-- Body Elements -->

<div class="container-fluid">

    <!-- Animated/Expanding Div -->

    <div class="row outeranimDiv-TGS" id="outeranimDiv">
        <div class="leftanimDiv col-lg-5" id="animDiv2"></div>
        <div class="animDiv-TGS col-lg-2" id="animDiv1"></div>
        <div class="rightanimDiv col-lg-5" id="animDiv3"></div>
    </div>

    <!-- End Animated/Expanding Div -->

    <!-- Actual Body -->

    <div class="row bodyTGS">
        Hello World!
    </div>

    <!-- End Actual Body -->

</div>

<!-- End Body Elements -->

<!-- Scripts -->
<script>
    $(document).ready(function() {
        $("#animDiv1").animate({
            height: "400px"
        }, 500);
        $("#animDiv2, #animDiv3").delay(501).animate({
            backgroundColor: "gray"
        }, 500);
    });

</script>
<!-- End Scripts -->


</body>

和CSS:

body {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
color: #333;
font-size: 12px;
background-color: black;
height: 100vh;
width: 100vw;
padding: 0;
}

.bodyTGS {
}

.outeranimDiv-TGS {
z-index: -1;
position: absolute;
top: 0px;
width: 100%;
text-align: center;
height: 400px;
}

.animDiv-TGS {
position: relative;
margin: 0 auto;
height: 2px;
width: 20%;
background-color: #ff9900;
}

.leftanimDiv {
position: relative;
margin: 0 auto;
background-color: black;
width: 40%;
height: 400px;
z-index: -1;
}

.rightanimDiv {
position: relative;
margin: 0 auto;
background-color: black;
width: 40%;
height: 400px;
z-index: -1;
}

.navbar-brand {
position: absolute;
font-size: 35px;
width: 100%;
left: 0;
text-align: center;
margin: 0 auto;
}

.navbar-toggle {
z-index: 3;
}

.navbar-right {
margin-right: 2px;
}

1 个答案:

答案 0 :(得分:0)

outeranimDiv-TGS类具有绝对位置

将绝对位置更改为浮动,然后清除浮动 或尝试此处建议的解决方案,以显示绝对位置后的静态元素 Static elements after position:absolute

目前尚不清楚您希望实现什么目标,您是否可以发布一张图片,显示您希望Hello World出现在哪里?