I have come across this code snippet
HTML
<div class="head">
<div class="menu">
</div>
<div class="search">
</div>
</div>
CSS
.head {
height:110px;
position:relative;
}
.menu {
float:left;
position:absolute;
bottom:0px;
}
.search {
float:right;
position:absolute;
bottom:0px;
}
The main goal is to position the div "menu"
at the bottom left of the div "head"
and the div "search"
at the bottom right of the div "head"
.
After experimenting with position and bottom values for the "menu"
and "head"
, it successfully aligns the menu, but the same approach causes the search box to overlap slightly on top of the menu.
An illustration can be viewed here: https://i.sstatic.net/KBUxw.png (The "menu" div aligns correctly; however, the "search" div is placed to the left and above the "menu" a bit higher)
Using just float without position and bottom values aligns them properly horizontally but fails to place them at the bottom of the parent container.
Although they are aligned to the sides, the "search" div still remains higher than the "menu" (and not positioned at the bottom).
This could be due to the presence of a form inside the input search field.
Edit1
: It was discovered that the issue lies in aligning the search box to the bottom of the "search" div. An attempt was made by adding the following to .searchbox
.searchbox {
vertical-align:bottom;
}
However, neither this nor bottom:0px; worked as expected.
Edit2
: A solution was identified after pinpointing the root cause of the problem. The addition of the following code to a class assigned to the input box resolved the issue
position: absolute;
right: 0;
bottom: 0;
As a result, everything now functions flawlessly. Since there is no other content inside "search" except for the box, aligning the "search" div is not a major concern as the input box aligns perfectly with "head". Appreciation to everyone involved!