p {
margin-top: 10px;
margin-bottom: 10px;
margin-right: 15px;
margin-left: 8px;
}
/* You can also write the above code in one line */
p{
margin: 10px 15px 10px 8px; /* top | right | bottom | left */
}
div.one {
margin: 20px; /* All around */
}
div.two {
margin: 20px 10px; /* vertical | horizontal */
}
div.three {
margin: 20px 10px 30px; /* top | horizontal | bottom */
}
div.four {
margin: 20px 10px 30px 40px; /* top | right | bottom | left */
}
/* Apply to all four sides */
margin: 1em;
margin: -3px;
/* vertical | horizontal */
margin: 5% auto;
/* top | horizontal | bottom */
margin: 1em auto 2em;
/* top | right | bottom | left */
margin: 2px 1em 0 auto;
/* Global values */
margin: inherit;
margin: initial;
margin: unset;
margin: auto;
/* Margin auto means, => element will take space according to it's size (in any container),
=> All remaining space around that element (in it's container / parent) will become it's margin */
p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
}
Margin
_____________________________________________________________________
| Border |
| ____________________________________________ |
| | Padding | |
| | _________________ | |
Margin | Border | Padding | Content | Padding | Border | Margin
| | _________________ | |
| | Padding | |
| |__________________________________________| |
| Border |
|___________________________________________________________________|
Margin
/* Apply to all four sides */
margin: 1em;
margin: -3px;
/* vertical | horizontal */
margin: 5% auto;
/* top | horizontal | bottom */
margin: 1em auto 2em;
/* top | right | bottom | left */
margin: 2px 1em 0 auto;
/* Global values */
margin: inherit;
margin: initial;
margin: revert;
margin: unset;
Save to mem.dev
#blockOrInline-Block {margin: 0px/*top*/ 0px/*right*/ 0px/*bottom*/ 0px/*left*/;}
margin-left:20 px;
margin: <margin-top> || <margin-right> || <margin-bottom> || <margin-left>
/* shorthand margin*/
.box {
margin: 20px;
}
/* The same margin written longhand */
.box {
margin-top: 20px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 20px;
}
margin: top right bottom left;
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
margin: 10px 5px 10px 5px;
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-size: 2rem;
}
body {
margin: 0px;
}
margin: 10px 15px 10px 8px; /* top | right | bottom | left */
Code Example |
---|
Css :: absolute center css |
Css :: install tailwind css in react |
Css :: how to make a responsive box in css |
Css :: how to give opacity to border |
Css :: center absolute element |
Css :: keyframe |
Css :: css before is not working |
Css :: star required css |
Css :: input area bootstrap highlight |
Css :: text change animation css |
Css :: have unordered list horizontal css |
Css :: css transparent color |
Css :: css image hover |
Css :: @media query css |
Css :: css floating div |
Css :: how to stop overflow in css |
Css :: attribute selectors css |
Css :: text-transform |
Css :: add background image in css |
Css :: zero two hair color code |
Css :: css grid auto row |
Css :: show arrow on hover css |
Css :: remove materialize style input |
Css :: how to change logo size in wordpress |
Css :: wave css |
Css :: add border to png image using css |
Css :: how to draw rhombus in css |
Css :: scale textarea |
Css :: centralizing a table with css |
Css :: icon circle css |