简体   繁体   中英

How can I only make the navigation bar in CSS transparent while keeping the text elements opaque?

This is a just a little project of mine, and I'm wanting to make a navbar where only the navbar itself is transparent while the text elements (anchors I think) are opaque. Thanks in advance,

Jacob

Here is my HTML:

    <!DOCTYPE html>

<html lang = "en">
    <head>
        <meta charset="utf-8">

        <meta name="description" content="Code Warriors STL">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="C:\\Users\\toshiba\\Desktop\\style.css">
        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
    </head>

    <body data-spy ="scroll" data-target = "nav">




        <nav class ="navbar navbar-inverse navbar-fixed-top">
            <div class ="container">
                <div class="navbar-header">
                    <a href="#" class="navbar-brand">Code Warriors</a>
                    <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>
                <div class ="collapse navbar-collapse" id = "navbar-collapse">
                    <ul class ="nav navbar-nav navbar-center">
                        <li><a href ="#">Home</a></li>
                        <li><a href ="#">About</a></li>
                        <li><a href ="#">Programs</a></li>
                        <li><a href ="#">Contact Us</a></li>
                    </ul>

                </div>

            </div> 
        </nav>

        <footer>

        </footer>
        <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
        <!-- Latest compiled and minified JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    </body> 

</html>

Here is my CSS

   .navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus {
color: #721639;/*Sets the text hover color on navbar*/
}

.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active >   
 a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
color: white; /*BACKGROUND color for active*/
background-color: #030033;
}

  .navbar-inverse {
    background-color: #0f006f;
    border-color: #030033;
}

  .dropdown-menu > li > a:hover,
   .dropdown-menu > li > a:focus {
    color: #262626;
   text-decoration: none;
  background-color: #66CCFF;  /*change color of links in drop down here*/
   }

 .nav > li > a:hover,
 .nav > li > a:focus {
    text-decoration: none;
    background-color: silver; /*Change rollover cell color here*/
  }


  .navbar-inverse .navbar-nav > li > a {
   color: white; /*Change active text color here*/
    }

.navbar-inverse .navbar-brand {
  color: #ffffff;
}
.navbar-inverse .navbar-brand:hover, .navbar-inverse .navbar-brand:focus {
  color: #721639;
}

.navbar-inverse: not(a) {

opacity: .78;

}

.navbar-wrapper{
    background: rgba(0,0,0,0.2);
}

html {

font-family: 'Open Sans', sans-serif;;
}

You mean something like this? Replace this rule for .navbar-inverse with this:

.navbar-inverse {
    background: rgba(15,0,111,0.6);
    border-color: #030033;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM