Floating elements within a div, floats outside of div. Why?
The easiest is to put overflow:hidden
on the parent div and don't specify a height:
#parent { overflow: hidden }
Another way is to also float the parent div:
#parent { float: left; width: 100% }
Another way uses a clear element:
<div class="parent">
<img class="floated_child" src="..." />
<span class="clear"></span>
</div>
CSS
span.clear { clear: left; display: block; }
float right element outside of parent
In your HTML, move the right-floated element before the element you want it to float around:
<div id="boards">
<p>TOP BOARDS</p>
<div id="board_items_container">
<div id="board1" class="board_items"> <!-- float: left -->
</div>
<div id="board3" class="board_items"> <!-- float: right -->
</div>
<div id="board2" class="board_items"> <!-- not floated -->
</div>
</div>
</div>
Floated element gets outside of its parent?
You can fix it by adding overflow:auto
to ul li
, if I understand your problem correctly.
Float image outside of parent container
something like this?
.parent { display:inline-block; width: 100px; height: 300px; background-color:lightgray; margin-left: 100px;}.child { width: 200px; height:100px; border-radius: 100px;; background-color:gray; position:abolute; margin-left: -50px; margin-top:100px;}
<div class='parent'> <img class='child'/></div>
Related Topics
Vertically Center a Div with Variable Height Within a Div That Is 100% of The Viewport
Which Browsers Still Support CSS Expressions
Overflow with Absolute/Relative Positioning Layout
How to Apply a CSS Stylesheet to All Page Views in My Firefox Browser
How to Disable Inline CSS in Gatsby
Why Won't My Visited Link Have a Background Color
Why Is Text in Disabled Form Elements Not Rendered in Black in Safari
What Is Position:Relative Useful For
Build a Proper Alignment for a Footer
Dynamically Changing Font, Font-Size, Font-Color, and So on in Vaadin Flow Web Apps
Internet Explorer 8 and Checkbox CSS Problem
How to Select <A> Only When There's No Text Around It
What Exactly Happens When a Browser Doesn't Support Media Queries