I am new to the world of coding as well as CSS and have noticed that when I resize my browser, all my float elements move to say the right and the user is forced to scroll horizontally to view say the menu.
Firstly is there a need to prevent float elements not changing their position?
Secondly, is there a way I can avoid this if I should be preventing it?
first add a parent div/wrap and put those two divs of yours into it. Overall, whatever size you add to the min-width itll scale the parent div down to the size specified. once the window is sized down past your specified size, itll behave like any other window. this is my way of doing it.
Definition and Usage Note: Elements next to a floating element will flow around it. To avoid this, use the clear property or the clearfix hack (see example at the bottom of this page).
One way to position elements on a page is with the float property. The float property is pretty versatile and can be used in a number of different ways. Essentially, the float property allows us to take an element, remove it from the normal flow of a page, and position it to the left or right of its parent element.
To clear a float, add the clear property to the element that needs to clear the float. This is usually the element after the floated element. The clear property can take the values of left , right , and both . Usually you'll want to use both.
Floats are a pain in the butt. Primarily because of the one browser that refuses to follow the universal web standards. Yeah, that one.
There are a million and one tricks to avoid these problems. I tell my team to follow these steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With