Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide elements if too small without js [closed]

Tags:

css

dynamic

size

I like to hide content, if the window size falls below a minimum size. I found an example (http://css-tricks.com/dynamic-page-replacing-content/), but I could not find out, why it works.

<div class="container">
    <div class="box left">foo1</div>
    <aside class="box right">foo2</aside>
</div>

The goal is, if the width of container falls below a specified minimum size aside will be hidden. That should work without javascript, just using css.

like image 502
Thomy800 Avatar asked Feb 18 '23 21:02

Thomy800


1 Answers

You are looking for is "CSS Media Queries".

Checkout this article for more information: http://mobile.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/

This example would accomplish what you are looking for with only CSS:

@media only screen and (max-device-width: 480px) {
  aside { 
    display:none;
  }
}

You might also check out twitter bootstrap to see how this is used to make responsive grid systems and classes that hide elements in specific contexts

like image 72
Thomas V. Avatar answered Feb 28 '23 07:02

Thomas V.