If you find yourself in a situation where float: right
is not behaving as expected, it may be due to a missing position
setting on a previous element. One possible solution is to change the position of the top left container to position: absolute
, which should result in the link moving to the top while still being floated to the right.
Another approach could be to utilize CSS flex for styling, which offers more flexibility. Below is an example of how you can achieve a similar layout using CSS flex:
.pull-right {
display: flex;
align-items: center;
}
.test {
display: flex;
width: 100%;
height: 50px;
background: red;
}
.test1 {
display: flex;
width: 100%;
height: 50px;
background: blue;
}
.test2 {
display: flex;
justify-content: flex-end;
width: 100%;
height: 50px;
background: green;
}
.input-group {
width: 100%;
height: 50px;
background: yellow;
}
<div class="test">
<div class="test1">
</div>
<div class="test2">
<a class="pull-right">My link</a>
</div>
</div>
<div class="input-group margin-top-md">
</div>