-
-
Save SarahElson/36702fc582baadafe78f64eab5374a0c to your computer and use it in GitHub Desktop.
Internal Spacing or Padding
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>Internal Spacing or Padding</h1> | |
<div class="box"> | |
<div class="p-top"> | |
<div></div> | |
<p>padding-top: 30px;</p> | |
</div> | |
<div class="p-right"> | |
<div></div> | |
<p>padding-right: 30px;</p> | |
</div> | |
<div class="p-bottom"> | |
<div></div> | |
<p>padding-bottom: 30px;</p> | |
</div> | |
<div class="p-left"> | |
<div></div> | |
<p>padding-left: 30px;</p> | |
</div> | |
<div class="p-allFourSides"> | |
<div></div> | |
<p>All four sides: 30px;</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 PADDING */ | |
.p-top { | |
padding-top: 30px; | |
} | |
.p-right { | |
padding-right: 30px; | |
} | |
.p-bottom { | |
padding-bottom: 30px; | |
} | |
.p-left { | |
padding-left: 30px; | |
} | |
.p-allFourSides { | |
padding: 30px; | |
} | |
/* -------------------------- */ | |
* { | |
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; | |
} | |
.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^="p-"] { | |
border: 4px solid tomato; | |
} | |
[class^="p-"] > 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