如何使用bootstrap显示此横幅?

时间:2016-03-03 17:59:27

标签: html css twitter-bootstrap

我试图让图片占据页面的宽度但由于某种原因它不会出现。我想我已经正确地设置了横幅的路径 背景图像:网址(' /images/banner.png');

HTML

<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel=stylesheet type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <title>Page Title</title>
</head>
<nav>

</nav>

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <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>
                <a class="navbar-brand" href="#">Shiny Leaf Studio</a>
            </div>
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">About</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Username</a></li>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </div>

    <div class="wide">
        <div class="col-xs-5 line">
            <hr>
        </div>
        <div class="col-xs-2 logo">Logo</div>
        <div class="col-xs-5 line">
            <hr>
        </div>
    </div>
</body>

</html>

CSS

body,html {
  height: 100%;
}

body {
  padding-top: 50px;
}

.wide {
  width:100%;
  height:100%;
  height:calc(100% - 1px);
  background-image:url('/images/banner.png');
  background-size:cover;
}

.wide img {
  width:100%;
}

.logo {
  color:#fff;
  font-weight:800;
  font-size:14pt;
  padding:25px;
  text-align:center;
}

.line {
  padding-top:20px;
  white-space:no-wrap;
  overflow:hidden;
  text-align:center;
}

1 个答案:

答案 0 :(得分:0)

尝试使用此clas sin .wide

<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel=stylesheet type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <title>Page Title</title>
</head>
<nav>

</nav>

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <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>
                <a class="navbar-brand" href="#">Shiny Leaf Studio</a>
            </div>
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">About</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Username</a></li>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </div>

    <div class="wide container-fluid">
        <div class="col-xs-5 line">
            <hr>
        </div>
        <div class="col-xs-2 logo">Logo</div>
        <div class="col-xs-5 line">
            <hr>
        </div>
    </div>
</body>

</html>