Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I make a website and make the background color of my nav-element to 0.7. I do this because on the background I'll place an image. On this image I've added an example and my code.

Here you could find my code:

HTML
<nav class="navbar">
    <ul class="nav">
        <li><a href="#">Log in</a></li>
        <li><a href="#">Register</a></li>
    </ul>
    <div class="cf"></div>
</nav>
<img src="http://www.siwallpaperhd.com/wp-content/uploads/2016/03/tv_series_viking_background_wallpaper.jpg"/>
CSS
body {
    margin: 0;
}

img {
    width: 100%;
    position: relative;
    top: -25px; // need height of navbar.
    z-index: -1;
}

nav {
    background-color: rgba(150, 0, 0, 0.7);
    margin: 0;
    
    ul {
        margin: 0;
        list-style-type: none;
        
        li {
            float: left;
            margin: 15px;
            
            a {
                color: white;
            }
        }
    }
}

.cf {
    clear: left;
}
Here you have an image.

Here you have a Fiddle[^].

Now my question is: how could I get the hight of my navbar with SaSS?

What I have tried:

Search on the internet but nothing found
Posted
Updated 24-Dec-16 22:17pm

1 solution

You are asking for the final - computed - height?
You can not... SASS can't do nothing that CSS can't do...
So the only options is specifying the height explicitly and use it as fixed value...

CSS
nav {
    background-color: rgba(150, 0, 0, 0.7);
    margin: 0;
    height: 50px;

    ul {
        margin: 0;
        list-style-type: none;
        
        li {
            float: left;
            margin: 15px;
            
            a {
                color: white;
            }
        }
    }

img {
    width: 100%;
    position: relative;
    top: -50px; // need height of navbar.
    z-index: -1;
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900