Solved

Div inherit width from other div?

Posted on 2009-07-10
7
1,351 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Suggested Courses

617 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