1

I am a newbie to bootstrap. I have developed a weppage using bootstrap3. I'm using these two classes on the same element, but the css is not having any effect:

HTML:

<div class="col-md-4 auminascroll">
    dfgdgdfgdfgsdfgh cxzvdzfhfdbfd fbfddf
</div>
<div class="col-md-4 auminascroll">fghfdghfdhdfhfdsh</div>
<div class="col-md-4 auminascroll">dfgdsgdsfg</div>

Css:

.col-md-4 .auminascroll {

   height: 50px;
   overflow-y: auto; 

}

I am not getting a scroll when using above code. If I put height: 50px; overflow-y: auto; in a style tag, my code works fine. Why is this css not having an effect when using it with this bootstrap class? Is there any problem with my code?

Any help will be greatly appreciated!!!

2
  • is bootstrap loaded in you webpage? css and js files? Commented Dec 8, 2014 at 12:56
  • seeing your html and CSS, the only plausible explanation would be that this CSS file is not loaded (up to you to check if it is) OR that this rule is overruled with a more specific one coming from somewhere else Commented Dec 8, 2014 at 12:57

2 Answers 2

5

You're nearly there! When using a selector to choose two classes there should be no space between the class names - they just need separating with a dot.

.col-md-4.auminascroll { /* no space between the two classes */

 height: 50px;
 overflow-y: auto; 

}

Your code (where there's a space between the two classes: .class-a .class-b would actually look for an element of class-b inside and element of class-a.

<div class="col-md-4">
    <div class="auminascroll">
    </div>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

Glad I could help, it can be confusing that multiple classes are separated with a space in HTML, yet a space denotes a descendant class in CSS. (if you'd like any more clarifications please let me know, and if you're happy please accept my answer)
i try to accept,but the alert shows you cannot accept answer in some minutes.i will accept the answer after time expires
2

You are using the wrong css selector. You need to use it like:

.col-md-4.auminascroll {

  height: 50px;
  overflow-y: auto; 

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.