Last active
February 6, 2023 15:54
-
-
Save AakashRao-dev/5df55265b2753a68740f90acf7c80caa to your computer and use it in GitHub Desktop.
External Spacing or Margin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h1>External Spacing or Margin</h1> | |
<div class="box"> | |
<div class="m-top"> | |
<div></div> | |
<div></div> | |
<p>margin-top: 60px;</p> | |
</div> | |
<div class="m-right"> | |
<div></div> | |
<div></div> | |
<p>margin-right: 60px;</p> | |
</div> | |
<div class="m-bottom"> | |
<div></div> | |
<div></div> | |
<p>margin-bottom: 30px;</p> | |
</div> | |
<div class="m-left"> | |
<div></div> | |
<div></div> | |
<p>margin-left: 60px;</p> | |
</div> | |
<div class="m-allFourSides"> | |
<div></div> | |
<div></div> | |
<p>All four sides: 60px;</p> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url("https://fonts.googleapis.com/css2?family=Rowdies&display=swap"); | |
/* MAIN CODE SHOWCASING THE USE OF MARGIN */ | |
.m-top > div { | |
margin-top: 60px; | |
} | |
.m-right > div { | |
margin-right: 60px; | |
} | |
.m-bottom > div { | |
margin-bottom: 60px; | |
} | |
.m-left > div { | |
margin-left: 60px; | |
} | |
.m-allFourSides > div { | |
margin: 60px; | |
} | |
/* -------------------------- */ | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
html, | |
body { | |
height: 100%; | |
} | |
body { | |
font-family: "Rowdies", cursive; | |
color: #262626; | |
} | |
.container { | |
width: 100%; | |
height: 100%; | |
border: 16px ridge #ff6550; | |
background: #ffe7e7; | |
text-align: center; | |
overflow: auto; | |
} | |
.box { | |
margin-top: 3rem; | |
display: grid; | |
grid-template-columns: repeat(3, minmax(200px, 1fr)); | |
justify-content: center; | |
align-items: center; | |
gap: 3rem; | |
padding: 2rem; | |
} | |
[class^="m-"] { | |
border: 4px solid tomato; | |
} | |
[class^="m-"] > div { | |
width: 100px; | |
height: 100px; | |
background: #d33a25; | |
} | |
@media (max-width: 900px) { | |
.box { | |
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment