Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluid layouts with CSS

Tags:

javascript

css

I have noticed on some sites that utilise a fluid layout, it is possible to remove elements on the page and replace elements when the window is shrunk to a smaller size, obviously to make the content easier to view.

ex: http://simplebits.com/

My question is.. what css is being used to make this happen (if it is css, perhaps JavaScript..)? what should I look at in order to learn more about this technique?

Thanks!

like image 493
Alex Avatar asked Jan 28 '11 13:01

Alex


People also ask

What is fluid layout?

Fluid layout is a layout that uses proportional values as a measurement unit for blocks of text, images, or any other object that is a part of the WordPress style (according to WordPress theme development terminology). This helps the web page stretch and contract in reaction to the scale of the user's screen.

What is the difference between fixed and fluid layouts?

Fixed-Width Layouts: These are layouts where the width of the entire page is set with a specific numerical value. Liquid Layouts: These are layouts where the width of the entire page is flexible depending on how wide the viewer's browser is.

What is fixed layout in CSS?

An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. A fixed element does not leave a gap in the page where it would normally have been located.


2 Answers

The stylesheet contains different rules for when the screen is less than 800px wide. If you look at the stylesheet for the page the on line 983 there is a @media rule as follows:

@media screen and (max-width: 800px) {
  /* Alternate rules here*/
}

This is a CSS3 feature so I guess that the site does not restyle as nicely for older browsers. Details of media queries can be seen at http://www.w3.org/TR/css3-mediaqueries/#width

like image 179
detaylor Avatar answered Oct 02 '22 04:10

detaylor


It uses CSS Media Queries. Look at the end of the CSS file:

http://simplebits.com/-/css/styles.css

like image 27
RoToRa Avatar answered Oct 02 '22 03:10

RoToRa