My webpage has a layout with a floated left sidebar, breadcrumbs, and the main content area on the right.
When inspecting the breadcrumbsContainer in the jsFiddle link provided, you may notice that its left edge aligns with the browser window's left edge instead of the right edge of the sidebar as expected.
I have searched for similar issues but have not found one with an answer yet.
Below is the HTML code:
<div>
<div id="sidebar">
<div class="menuItem">Users</div>
<div class="menuItem">Settings</div>
</div>
<div class="breadcrumbsContainer">
Breadcrumbs go here
</div>
<div class="main">
Main content goes here
</div>
</div>
And the CSS:
#sidebar {
float: left;
width: 200px;
}
.menuItem {
height: 60px;
border-top: 1px solid white;
background: lightBlue;
}
.breadcrumbsContainer {
height: 24px;
background: lightGrey;
}
.main {
background: #f5f5f5;
overflow: scroll;
}
jsFiddle
Notes
The .main div is positioned as expected.
Removing the overflow:scroll from the .main div caused it to behave like the breadcrumbsContainer.
Adding overflow:scroll (or overflow:hidden) to the breadcrumbsContainer adjusted its bounding box.
Questions
Why does the breadcrumbsContainer's bounding box start differently than expected, even though its text displays correctly?
What is the correct way to set up this layout without overlapping elements and ensure they resize with the browser window?
I could easily achieve this using absolute positioning and jQuery's resize() event, but I believe there should be a better solution.
Thank you.