0
Thanks

A few words of thanks would be greatly appreciated.

CSS - Define the vertical height based on an element




Sometimes we want to define a vertical height of a page, based on a specific element.
It is quite simple to implement, using fixed values (not pixels), but it's more complicated when using relative heights (percentage).

This problem is often encountered when using background images to create a border with a certain style to an element.
To set a vertical height on an item, it is necessary that every parent element have a defined height too.

We must define a height tags to html, body, and all tags containing the element must have a certain height.

This gives for example:

html,body,div#body,div#all_my_elements{height:100%}
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Original article published by . Translated by deri58. Latest update on by jak58.

This document, titled "CSS - Define the vertical height based on an element," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments