Solved

Div inherit width from other div?

Posted on 2009-07-10
7
1,347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

734 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