Website layout that resizes with different widths?

Does anyone know how to accomplish a different layout based on browser width like these two sites?

I tried google, looked at Stackoverflow questions and looked at their code, but I think I am missing something. It actually rearranges and resizes some of the elements based on the width of the window, but how? Javascript?

Sorry if my search skills are just failing, but I'm not really sure what to look for, the "similar questions" here don't seem to be related, and even CSS-Tricks has no easy-to-find information.


source to share

4 answers

You don't need to use JS to determine the browser width. You can just use CSS media queries to change the layout.

For example:

@media screen and (max-width: 1280px) {
    ... selector(s) here ...


Applies CSS only to screens up to 1280 pixels wide.

See also:



You can use CSS3 media queries to deliver different styles based on screen width. See here for more information:

If you look at the CSS source of, for example, you can see what they do: . Search for "@media-only screen" and you will see that they supply different CSS for widths below 768px, between 768-1024px and above 1024px.



You can reinvent the wheel, or you can simply build / redesign your website using one of the many flexible frameworks that are available. I've used both Skeleton and Bootstrap by Twitter. Their framework can be found in ... Skeleton ... [ Their [1] Bootstrap ... [] [2]

I have built sites using each ... Skeleton ... [] [3] Bootstrap ... [] [4]

I'm still trying to decide which I prefer, but right now the boot strap seems to offer more options.



Maybe a little jMasonry , but this is also a bit like what Twitter Bootstrap provides in rails, it might be worth pouring their static version of the CSS for the answers.



All Articles