I have the following snippet to render an icon overlapped with another. The whole div is a link. Currently I'm using position:absolute and adjusting the overlap. How can I do it without the absolute position. I also want the whole div on the right side of the screen (currently its on the left).
.btn-circle {
position: absolute;
top: 4px;
left: 25px;
width: 30px;
height: 30px;
line-height: 30px;
background: red;
border-radius: 50%;l
}
.count {
position: absolute;
top:8px;
left:38px;
font-size:16px;
font-weight: bold;
color:white;
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<div class="">
<a href="#">
<i class="fa fa-inbox fa-2x"></i>
<span id="red-circle" class="btn btn-circle"></span>
<span id="toDosCount" class="count">9</span>
</a>
</div>
You can still use absolute positioning alongside
float: right
if you make the containing div haveposition: relative
This makes the absolute positions of the inner spans relative to the div rather than the page.
A few tweaks to the top and right/left values and:
I also nudged the whole thing to the left a little so it wasn't obscured by the snippet FULL PAGE