Div inherit width from other div?

Hi Experts!

Can I make a div class inherit width from another div class?

Thanks!
LVL 2
AphXAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
David S.Connect With a Mentor Commented:
Yes and no.  An element can belong to multiple classes, an element may inherit some styles from its parent, and a style rule may be applied to multiple classes.  Otherwise the answer is probably "no".
0
 
AphXAuthor Commented:
Hmm okay. I have this problem:

<div class="div1">
<div class="div2">
<p>Some text</p>
<p>a lot of text</p>
</div>
</div>

Only div2 is adjusting it´s height depending on how much text there is. I want both divs to do the same thing.

Is it possible?
0
 
Chad HaneyConnect With a Mentor Chief Technology OfficerCommented:
if div1 has a height defined you can match the height with div2 by using height:100%;
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
AphXAuthor Commented:
Thank you guys!
0
 
David S.Commented:
You're welcome?

If ".div2" is floated then you need to tell its parent to contain it. Floating the parent of the floated element(s) is a good simple option in some cases and in others the PIE/Aslett approach works well.

More information: http://www.dynamicsitesolutions.com/css/layout-techniques/#clearing_floats
0
 
David S.Commented:
Oops. Typo. I didn't mean that first sentence to end in a question mark. It should be just:

You're welcome.
0
 
AphXAuthor Commented:
:D

Thank you man!

I really appreciate your invaluable help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.