Solved

bootstrap add a css class in media query

Posted on 2014-09-30
3
1,488 Views
Last Modified: 2014-10-04
I have a button group div #xxx

In side my css class file , I am trying to write a media query

@media (min-width: 768px) and (max-width: 992px) {
    div#xxx {
         - here I need to add "btn-group-lg" class
    }
}


@media (min-width: 992px) {
     div#xxx {
         - here I need to add "btn-group-sm" class
   
}

I am not able to do so, is there any way of adding a css class inside css file
0
Comment
Question by:yadavdep
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40351631
I'm not sure if I understood what you want but...
You're using SASS?
And you have to style a div like: <div id="xxx" class="btn-group-sm">

In SASS you can do:
@media (min-width: 992px) {
     div#xxx {
         &.btn-group-sm {

         }
}

Open in new window

& before the class name means that that class is at the same level as the "container"
0
 

Author Comment

by:yadavdep
ID: 40351644
I am in an asp.net project and in  an css file I want to add a specific class to my div on a specific screen size .
If the screen is small then I want to add other class  "btn-group-sm"
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 40351661
Well, it doesn't work like that.
Unless you want to do that with javascript, your pure css way to do that is to hide/show the groups depending on the media size:
  <body>
    <div class="hidden-xs btn-group btn-group-lg">
      <button type="button" class="btn btn-default">Left</button>
      <button type="button" class="btn btn-default">Middle</button>
      <button type="button" class="btn btn-default">Right</button>
    </div>
    <br/>
    <div class="hidden-lg btn-group btn-group-xs">
      <button type="button" class="btn btn-default">Left</button>
      <button type="button" class="btn btn-default">Middle</button>
      <button type="button" class="btn btn-default">Right</button>
    </div>
  </body>

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question