Having trouble positioning the button in the bottom-right corner of the parent div? I attempted using float: right;
, but it ended up outside of the box. How can I keep the button within the box and align it to the bottom-right corner?
If you have a solution, could you also explain why using float:right; causes the button to move out of the box?
.color {
border: 1px solid black;
width: 70%;
margin: 10px auto;
padding: 0 30px;
position: relative;
}
.color p {
display: inline-block;
width: 200px;
height: 80px;
margin-right: 10px;
text-align: center;
line-height: 78px;
}
p.black {
background: black;
color: white;
}
p.gray {
background: gray;
color: white;
}
p.blue {
background: blue;
color: white;
}
p.white {
border: 1px solid black;
}
.btn a {
display: inline-block;
border: 1px solid black;
color: black;
padding: 10px;
margin: 10px 0;
text-decoration: none;
font-size: 90%;
font-weight: 700;
border-radius: 50px;
text-align: center;
box-shadow: inset 0 0 0 0 #000000;
transition: ease-out .2s;
}
.color .btn a:hover {
box-shadow: inset 133px 0 0 0 #000000;
color: white;
}
<div class="color">
<h1 class="heading">Color</h1>
<p class="black">black</p>
<p class="gray">gray</p>
<p class="white">white</p>
<p class="blue">blue</p>
<div class="btn"><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value" target="_blank">See more colors</a></div>
</div>