导航栏周围的背景图片和下面的文字

时间:2018-09-27 17:16:23

标签: html css materialize nav

我正在一个网站上工作,但是在获取导航和全宽背景方面存在一个小问题。它卡在容器中。还有其他方法吗?我尝试了一些东西,但无法使其正常工作,所以我希望这里有个主意:)

很难解释,所以这里是我要说的话。Example

.social-nav ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.social-nav li {
    float: left;
}

.social-nav li a {
    display: block;
    text-align: center;
    padding: 8px;
    text-decoration: none;
    color: black;
    font-size: 16px;
    font-style: normal;
    font-weight: bolder;
}

.parallax-container{
    height: 550;
}

.nav-image {
    background-image: linear-gradient(
      rgba(0, 0, 0, 0.6), 
      rgba(0, 0, 0, 0.6)
    ), url("https://i.imgur.com/LZml73k.jpg");
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
    color: white;
}

.nav-image {
    text-transform: none;
    font-weight: normal;
}

.nav-image .nav-btn {
    background-color: transparent;
    border: 1px solid white;
    border-radius: 28px;
    font-weight: bold;
}

#nav-text {
    font-weight: normal;
    text-transform: none;
}

nav {
    background-color: #ff0000;
<!DOCTYPE html>
<html>
<head>
    
    <!-- Materialize css & Icons -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    
    <!-- Font awesome icons -->
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

    <!-- Google Fonts -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
    
    <!-- Eigen styles -->
    <link rel="stylesheet" type="text/css" href="style.css">
    
</head>
 
<body>
    
<!-- Navigatie -->
    
<header>
    
<div class="container">
    <div class="parallax-container">  

    <div class="row">

        <div class="col s12">
              <ul class="right social-nav">
                    <li><a href="https://www.instagram.com/?hl=nl"><i class="fab fa-instagram"></i></a></li>
                    <li><a href="https://www.facebook.com/"><i class="fab fa-facebook-f"></i></a></li>
                    <li><a href="https://plus.google.com/discover"><i class="fab fa-google-plus-g"></i></a></li>
                    <li><a href="https://twitter.com/?lang=nl"><i class="fab fa-twitter"></i></a></li>
              </ul>
        </div>
    </div>

        <nav>
            <div class="nav-wrapper">
                <ul id="nav-mobile" class="right hide-on-med-and-down">
                    <li><a href="sass.html">Sass</a></li>
                    <li><a href="badges.html">Components</a></li>
                    <li><a href="collapsible.html">JavaScript</a></li>
                </ul>
            </div>
        </nav>
        
        <div class="nav-image">
            <div class="row">
                <div class="col s7">
                
                <h1>Lorem ipsum dolor sit amet, consectur </h1>
                    
                <h5 id="nav-text">Lorem ipsum dolor sit amet, consectur adipisicing elit sed do ltd eiusmod tempor incididunt ut labore et dolore.</h5>
                <br> <a class="btn-large nav-btn">LEARN MORE</a>
                </div>
                    
                <div class="col s5 right">
                    <img class="right" src="https://i.imgur.com/4jt6Y4F.png">
                </div>
                
            </div>
        </div>
    </div>
</div>
    
</header>
  
  
      <!--  jquery & materialize js-->
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    
    
</body>
</html>

2 个答案:

答案 0 :(得分:0)

您尝试将整个页面设置为背景图像吗?

body {
   background-image: url("paper.gif");

}

答案 1 :(得分:0)

您可以尝试

body, html {
    height: 100%;
    margin: 0;
    background-image: url("img_girl.jpg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}