sun
sun

Reputation: 1668

how to control width and height of child div?

hi i have a div bat with

#bat{
     width:50%;
     height:50%;
     }

html

<div id="bat">dynamic div will occur</div>

when dynamic div are placed if the content is larger than #bat width and height those content are overflowing.i can hide that using overflow hidden in #bat but i don't want it to be that way. i want dynamic div to fit into #bat.thought of jquery child selector and then control them giving width and height to dynamic div.i don't know to select dynamically. can anybody help?

Upvotes: 0

Views: 254

Answers (3)

Danial
Danial

Reputation: 79

Try this:

width:auto;
height:auto;
display:block;

Upvotes: 0

Amit Sarwara
Amit Sarwara

Reputation: 573

if you want to give your child div dynamic space then your parent div must have the appropriate space. if your parent div don't have enough space then it will overflow.

So you have to give your parent #bat a minimum and maximum height and width. That can be done by CSS you don't need Jquery selector for that.

you can give

min-height: max-height: min-width: max-width:

so your content will be remained in this div only there will not be any overflow until your max height reached.

Upvotes: 1

OneOfOne
OneOfOne

Reputation: 99332

You should use min-width/height instead.

#bat {
     min-width:50%;
     min-height:50%;
}

Edit :

The problem is you were setting the width/height on your dynamic content, you can't do that.

http://jsfiddle.net/LWAjR/4/

Upvotes: 0

Related Questions