Solved

Div inherit width from other div?

Posted on 2009-07-10
7
1,338 Views
Last Modified: 2013-11-19
Hi Experts!

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

Thanks!
0
Comment
Question by:AphX
  • 3
  • 3
7 Comments
 
LVL 42

Accepted Solution

by:
David S. earned 250 total points
ID: 24828514
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
 
LVL 2

Author Comment

by:AphX
ID: 24830201
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
 
LVL 12

Assisted Solution

by:Chad Haney
Chad Haney earned 250 total points
ID: 24831758
if div1 has a height defined you can match the height with div2 by using height:100%;
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Closing Comment

by:AphX
ID: 31602302
Thank you guys!
0
 
LVL 42

Expert Comment

by:David S.
ID: 24833226
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
 
LVL 42

Expert Comment

by:David S.
ID: 24833230
Oops. Typo. I didn't mean that first sentence to end in a question mark. It should be just:

You're welcome.
0
 
LVL 2

Author Comment

by:AphX
ID: 24833595
:D

Thank you man!

I really appreciate your invaluable help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

25 Experts available now in Live!

Get 1:1 Help Now