Twitter Bootstrap: Set specific CSS rule for different sizes

Asked

Viewed 324 times

5

I would like to know how to declare a value to a CSS property according to browser resolution in Bootstrap.

Example: I want an edge to be displayed only on smartphones or very small resolutions (col-Xs). The bootstrap provides an easy way to do this?

1 answer

3


For this you will need to use the media query of css 3. Let’s look at your example:

All elements containing the class .borda should have a 1px border on devices with screen less than 768px wide (mobile phones), so in CSS we must define the following rules:

/* Todos os elementos que contenham a classe 'borda' terão uma borda de 1px preta */
.borda{ border: 1px solid #000; }

/* Agora apenas os dispositivos que tenham resolução menor que 768px terão borda */
@media (min-width: 768px){
  .borda{ border: none; }
}

Note: The above example was given based on this link

  • @Caputo, I removed its edition because the comment was correct, the media query serves exactly so that devices with a resolution of at least 768px do not have border, so devices with less than 768px will have border.

  • Oops, so it was my understanding failure there. Sorry and thank you for the warning! I misinterpreted the min-width

  • Perfect, Matthew. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.