Samuel Charpentier
Samuel Charpentier

Reputation: 609

CSS 100% height trouble again

Okay so i have this menu I got to do, it need to be at least 100% of the page ( but not the actual css 100% because i have some pading and margins on it so it get too long ) and it has to grow even bigger if the scren size is too small to show all of the links.

html:

<div id="menu">
    <a href="index.html"><button><img src="img/open.png"/><div>Acceuil</div></button></a>
    <a href="carte.html"><button><img src="img/toggled.png"/><div>La carte</div></button></a>
    <a href="traiteur.html"><button><img src="img/toggled.png"/><div>Service traiteur</div></button></a>
    <a href="reservation.html"><button><img src="img/toggled.png"/><div>Réservation</div></button></a>
    <a href="gite.html"><button><img src="img/toggled.png"/><div>Gîte</div></button></a>
</div>

CSS:

#menu{
    background-color: #850101;
    box-shadow: inset 0 0 25px rgba(0,0,0,.45);
    padding-top: 114px;
    margin-left: 5%;
    min-height: auto;
    display: block;
    height:auto;
    bottom:0;
    top:0;
    left:0;
    right:0;
    z-index: 1
}
#menu button{
    background-color: #640404;
    box-shadow: inset 0 0 25px rgba(0,0,0,.45);
    border: none;
    width: 100%;
    color: #fff;
    font-size: 30px;
    height: 60px;
    text-align: left;
    padding: 5 0;
    margin-bottom: 7px;
}
#menu button:hover{
    background-color: rgba(94,1,1,0);
}
#menu img{
    margin-right: 30px;
    padding-bottom: 2px;
    margin-left: 5px;
}
#menu button div{
    display: inline;
    position: absolute;
}

Upvotes: 0

Views: 146

Answers (1)

Jezen Thomas
Jezen Thomas

Reputation: 13800

box-sizing to the rescue!

#menu {box-sizing: border-box; min-height: 100%; padding: whatever;}

Prefixed versions are:

  • -moz-box-sizing: border-box;
  • -webkit-box-sizing: border-box;

Browser support is pretty darn good. Plays nicely with jQuery too.

Upvotes: 2

Related Questions