I'm attempting to expand my body tag to full browser height to fully display background color. I understand there are some solutions that suggest using html tag height of 100% and body tag with height of 100% or min-height of 100%.
I have found a solution (below) that has achieved the same result by specifying a min-height of the full view port and this works on different browsers. Could I use this as an alternative solution? If any, what are the disadvantages of this solution? Please provide some supporting evidence.
body {
background-color:#ea7400;
height: 100%;
min-height: 100vh;
}
@Josethehose provided a comment directing me to useful information on my question. See min-height in vh vs % for body?
While my solution did work, I don't believe it is the optimal solution because it uses unnecessary code.
Explanation:
The html, and body tags don't have default heights and can be sized relative to their parent elements. The hierarchy is Viewport > HTML > Body. The actual size of the browser screen is Viewport, so specifying the height: 100%
for the html tag will ensure it is the full height of its parent element or the Viewport. The height: 100%
can be coupled with the body tag to achieve full height of the parent element or the html tag which is inherited from the Viewport.
The optimal solution would be:
html,
body {
height: 100%;
}
I'm not able to pass the state value to the method or function in React [closed]
How to access array index of Cloud Firestore using query in Flutter?
Getting an unwanted space between Nav Items in Navbar Angular
PHP Script INSERT INTO SELECT does not insert, with no errors [closed]
SQL query to select students who have taken all subjects from subjects table
Displaying Dynamic placeholder content on Textbox in ReactJS
Extracting Parameters from Redirect URI - QuickBooks API / Python
This question already has an answer here: