Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i try to customize the height of my menu for html which are equally with the total height of my browser

but i found that when i set the height of my menu as 100%
it was not the height i want
before i set the height i made a title bar
so i found that the height of my html file was equal to my height of title bar + 100% of the height of web browser

when i try to set the height as :

height : 100% - (value for the height of title bar )

the value of my menu return to the normal size

can anyone correct my code?
I will attach my code below

What I have tried:

.titleBar{
height : 45;
}

.navMenu{
height : 100% - 45px;
}
Posted
Updated 21-Jan-17 3:02am

1 solution

To set some dimension based on certain percentage of the parent container, you must set the dimension of the parent container first. e.g.
<!DOCTYPE html>
<html>
<head>
<style>
html, body { 
	height: 100%;
	margin:0 }
div {
    height:100%;
    background:green;
}
</style>
</head>
<body>
<div>Menu</div>
</body>
</html>
Or, you can use the unit of
vh
Refer:
1. CSS Units[^]
2. Viewport units: vw, vh, vmin, vmax - Web Design Weekly[^]
 
Share this answer
 
v2

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