Setting the width of absolutely-positioned elements

One way to set the height of an element to 100% is to absoultely-position it yet you needed a max-width for it to follow (instead of a simple width) for layout reponse purposes.

The solution is to simply set its width to 100% and set the max-width to your desired value. For example:

[code lang=”css” title=”CSS”]
div {
position:absolute;
width:100%;
max-width:1280px;
height:100%;
background-color:red;
}
[/code]


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *