Solved

bootstrap add a css class in media query

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 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

16 Experts available now in Live!

Get 1:1 Help Now