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?
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:
I'd suggest you figure out if you want to support differing resolutions, depending on your target audience. Elements moving around isn't necessarily a bad thing, and planning in advance how you want your site to layout depending on viewport size could be important.
If you can't find a fixed-width, "one layout to rule them all" that works for your needs, take a look at CSS media queries . For a more practical article on them, try A List Apart
The basic idea is that, using separate stylesheets that depend on size, you can basically display a different layout to the user depending on their viewport. Users resizing their browsers will be able to see the new layout dynamically as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.