The pink block li elements in my code are spaced out because I used margins, but I've that it better to use padding in this case, except every time I try to replace the margin properties with padding, I cannot separate the pink blocks from each other. How do I use padding instead of margins to space out the li elements?
I tried googling stuff about this, but all that comes up are more practical applications of CSS like styling a website and spacing text, and I can't figure out how it applies to my work.
This is what it should look like (which I made using margin properties)
.blue-container {
background-color: #141f40;
height: 100px;
width: 400px;
position: relative;
}
.white-container {
background-color: #fff;
height: 60px;
width: 160px;
position: absolute;
top: 20px;
left:220px;
}
.white-container > li{
background-color: #a9004b;
height: 40px;
width: 40px;
float: left;
margin-top: 10px;
margin-left: 10px;
}
<!DOCtype HTML>
<html lang="jp">
<head>
<title>Siblings</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.18.1/build/cssreset/cssreset-min.css">
</head>
<body>
<main>
<div class="blue-container">
<ul class="white-container">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
</main>
</body>
</html>