EOB
EOB

Reputation: 3085

Changing the size of a div with a class?

I have this div in my code:

<div id="advice" class="validation-advice" style="">some text here</div>

Now, can I use a selector or something to say that all divs with the class validation-advice should only have a width of lets say 100px?

I tried:

div.validation-advice{
   width:100px;
}

Strange thing is, the div width changes (I used Firebug to see) but the text inside the div does not wrap when the div ends. Whats missing?

Thanks!

Upvotes: 0

Views: 95

Answers (3)

c97
c97

Reputation: 575

probably your divs have display:inline, try this:

div.validation-advice{
  display: block;
  width:100px;
}

Upvotes: 0

ventsislaf
ventsislaf

Reputation: 1671

It's a piece of cake!

.validation-advice {
    width: 100px;
}

Upvotes: 0

Sven Bieder
Sven Bieder

Reputation: 5681

div.validation-advice{
  width:100px;
}

The problem that your text not wraps at the end of the div is because you just enter plain text. If you do it like this you have no problems:

<div class="validation-advice">
  <p>Your text here</p>
</div>

Upvotes: 1

Related Questions