Solved

bootstrap add a css class in media query

Posted on 2014-09-30
3
1,426 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now