Quantcast
Channel: CSS 100% height with padding/margin - Stack Overflow
Browsing latest articles
Browse All 16 View Live
↧

Answer by user3113626 for CSS 100% height with padding/margin

To add -webkit and -moz would be more appropriate-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;

View Article


Answer by Freestyle09 for CSS 100% height with padding/margin

This is the default behavior of display: block The fastest way that you can fix it in 2020 is to set display: 'flex' of parent element and padding e.g. 20px then all its children will have 100% height...

View Article

Answer by Putzi San for CSS 100% height with padding/margin

A solution with flexbox (working on IE11): (or view on jsfiddle)<html><style> html, body { height: 100%; /* fix for IE11, not needed for chrome/ff */ margin: 0; /* CSS-reset for chrome */...

View Article

Answer by Kris Randall for CSS 100% height with padding/margin

Border around div, rather than page body marginAnother solution - I just wanted a simple border around the edge of my page, and I wanted 100% height when the content was smaller than that.Border-box...

View Article

Answer by Stickers for CSS 100% height with padding/margin

1. Full height with paddingbody { margin: 0;}.container { min-height: 100vh; padding: 50px; box-sizing: border-box; background: silver;}<div class="container">Hello world.</div>2. Full...

View Article


Answer by ktbiz for CSS 100% height with padding/margin

Another solution: You can use percentage units for margins as well as sizes. For example:.fullWidthPlusMargin { width: 98%; margin: 1%;}The main issue here is that the margins will increase/decrease...

View Article

Answer by Brian Aderer for CSS 100% height with padding/margin

The better way is with the calc() property. So, your case would look like:#myDiv { width: calc(100% - 10px); height: calc(100% - 10px); padding: 5px;}Simple, clean, no workarounds. Just make sure you...

View Article

Answer by user1721135 for CSS 100% height with padding/margin

Another solution is to use display:table which has a different box model behaviour.You can set a height and width to the parent and add padding without expanding it. The child has 100% height and width...

View Article


Answer by Peter Tseng for CSS 100% height with padding/margin

Frank's example confused me a bit - it didn't work in my case because I didn't understand positioning well enough yet. It's important to note that the parent container element needs to have a...

View Article


Answer by Mujassir Nasir for CSS 100% height with padding/margin

<style type="text/css">.stretchedToMargin { position:absolute; width:100%; height:100%;}</style>

View Article

Answer by Marco Jardim for CSS 100% height with padding/margin

There is a new property in CSS3 that you can use to change the way the box model calculates width/height, it's called box-sizing. By setting this property with the value "border-box" it makes whichever...

View Article

Answer by amolk for CSS 100% height with padding/margin

The solution is to NOT use height and width at all! Attach the inner box using top, left, right, bottom and then add margin..box {margin:8px; position:absolute; top:0; left:0; right:0; bottom:0}<div...

View Article

Answer by Frank Schwieterman for CSS 100% height with padding/margin

I learned how to do these sort of things reading "PRO HTML and CSS Design Patterns". The display:block is the default display value for the div, but I like to make it explicit. The container has to be...

View Article


Answer by Alex for CSS 100% height with padding/margin

According the w3c spec height refers to the height of the viewable area e.g. on a 1280x1024 pixel resolution monitor 100% height = 1024 pixels.min-height refers to the total height of the page...

View Article

Answer by Lawrence Dol for CSS 100% height with padding/margin

This is one of the outright idiocies of CSS - I have yet to understand the reasoning (if someone knows, pls. explain).100% means 100% of the container height - to which any margins, borders and padding...

View Article


CSS 100% height with padding/margin

With HTML/CSS, how can I make an element that has a width and/or height that is 100% of it's parent element and still has proper padding or margins?By "proper" I mean that if my parent element is 200px...

View Article
Browsing latest articles
Browse All 16 View Live