Height Of Html With Body And Default Margin On Chrome
Solution 1:
html, body { margin: 0; }
body { padding: 8px; }
*, *:before, *:after { box-sizing: border-box; }
Solution 2:
As I believe you want to keep the outer gradient I don't think setting margin:0
and/or padding:0
will help since it will remove the gradient border effect, but you can do it like this:
JS Fiddle - tested on Chrome, Firefox and IE11
body { height:calc(100% - 16px); }
UPDATED
As stated in a comment the above, as the other answer, won't wrap content if the content exceeds the window height, to fix this we need a combination of calc()
and viewport unit vh
for the .divz
div , as you can CSS need to have these lines:
html { min-height: 100%; }
body { height:100%; }
.divz {
padding:5px;
/***
full view height -
{ (8px*2) default top and bottom padding + (5px*2) .divz top and bottom padding }
= 100vh - 26px
***/min-height:calc(100vh - 26px);
}
JS Fiddle 2 - updated - tested on Chrome47, Firefox43 and IE11
Full Code : -updated
html {
min-height: 100%;
background: rgb(42,69,66);
background: -webkit-linear-gradient(top, rgba(73,94,8,1) 0%, rgba(145,232,66,1) 100%) no-repeat;
}
body {
height:100%;
}
.divz {
background-color: olive;
min-height:calc(100vh - 26px);
padding:5px;
}
<divclass="divz">
Candy canes dragée chocolate cake. Dragée cookie pastry. Sesame snaps macaroon croissant tootsie roll sesame snaps tootsie roll. Oat cake cotton candy wafer halvah tart chocolate cake croissant cookie. Sesame snaps carrot cake chupa chups pastry. Danish
dragée bonbon jujubes dessert croissant bonbon jelly-o. Bear claw caramels topping. Candy candy candy jelly powder gummi bears. Jelly-o cotton candy fruitcake pastry apple pie toffee powder pudding. Dessert bonbon marshmallow donut. Gummi bears dessert
cake cake gummies dragée soufflé. Candy canes muffin marshmallow carrot cake pastry sweet. Macaroon jelly-o icing biscuit lollipop bonbon chocolate bar jelly beans icing. Sweet biscuit liquorice cookie chocolate bar ice cream pudding cheesecake. Ice
cream marzipan cheesecake lemon drops. Macaroon gummies carrot cake cheesecake fruitcake candy canes caramels chocolate bar. Fruitcake chocolate bar soufflé donut soufflé topping sweet muffin. Chocolate chocolate bar marzipan caramels dessert candy
canes macaroon oat cake muffin. Cake cookie halvah jelly beans brownie candy chocolate cake macaroon. Wafer marzipan chocolate bar marzipan bear claw sugar plum. Sugar plum lemon drops fruitcake icing bear claw chocolate bar. Marshmallow sesame snaps
sesame snaps pastry cake tootsie roll oat cake. Cake chocolate bar cake tart tart bonbon jujubes. Macaroon muffin dessert candy muffin ice cream toffee lollipop tart. Liquorice sugar plum lollipop. Sesame snaps fruitcake tart dessert tart wafer jelly
beans tootsie roll. Cotton candy gummi bears cupcake cotton candy soufflé. Jelly beans topping soufflé pie wafer wafer brownie. Muffin icing halvah cookie candy sesame snaps cookie. Cotton candy tiramisu sweet bonbon tootsie roll powder tootsie roll
bonbon fruitcake. Icing cookie tootsie roll. Pie donut marzipan. Sesame snaps pastry bonbon bonbon marshmallow caramels carrot cake bear claw. Fruitcake cotton candy gummi bears dragée liquorice toffee jelly. Candy caramels sweet roll. Bear claw tart
macaroon cookie ice cream candy. Oat cake tootsie roll sesame snaps bear claw topping gummies. Apple pie jelly beans gummi bears cupcake cotton candy candy. Chocolate marshmallow sweet roll tiramisu candy gingerbread liquorice cupcake cake. Sweet roll
cookie gummi bears. Croissant gummi bears halvah. Bear claw caramels icing cotton candy sweet oat cake cookie. Sweet roll donut jujubes sugar plum donut muffin pie. Macaroon tiramisu tootsie roll ice cream bear claw wafer cake pudding biscuit. Jelly-o
gummi bears ice cream marshmallow sugar plum sugar plum caramels candy. Gummi bears chocolate bar cheesecake dessert. Toffee carrot cake candy marzipan carrot cake topping candy cake dragée. Tootsie roll chocolate cake powder tiramisu. Bear claw chocolate
jelly croissant liquorice tootsie roll chocolate bar jelly-o lemon drops. Caramels biscuit pie apple pie marzipan tiramisu jelly-o wafer chocolate bar. Chupa chups jelly-o chocolate tiramisu. Pudding jelly cupcake. Halvah candy canes sesame snaps brownie
chupa chups gummies candy bear claw. Sweet cupcake muffin sweet cake liquorice. Danish chocolate bar dragée macaroon cake brownie. Pastry liquorice tiramisu powder ice cream gummies pastry. Muffin jelly-o lemon drops lollipop candy canes sweet. Soufflé
pudding ice cream sweet roll. Dessert biscuit dessert cake sweet gummies sesame snaps. Chupa chups carrot cake cupcake lemon drops bonbon cookie. Gummies sweet roll icing oat cake cookie muffin pudding. Tootsie roll toffee carrot cake donut icing sweet
roll topping lollipop. Sugar plum fruitcake cupcake jelly croissant tiramisu cake donut. Wafer gummi bears sweet roll. Sesame snaps biscuit carrot cake wafer. Liquorice caramels dragée tootsie roll fruitcake. Jelly beans pudding toffee lollipop pudding
oat cake sweet. Chocolate danish jelly-o bear claw.
</div>
--------------------------------------------------------------------------------
Note that if you're going to target older browsers like IE8 and below and android < 4.3 as well then you need to have javascript code as fallback.
Solution 3:
Add this line to top of your css file, it will solve your problem
* {margin:0; padding:0}
Post a Comment for "Height Of Html With Body And Default Margin On Chrome"