Solved

Div inherit width from other div?

Posted on 2009-07-10
7
1,337 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
Comment Utility
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
Comment Utility
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
Comment Utility
if div1 has a height defined you can match the height with div2 by using height:100%;
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Closing Comment

by:AphX
Comment Utility
Thank you guys!
0
 
LVL 42

Expert Comment

by:David S.
Comment Utility
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.
Comment Utility
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
Comment Utility
:D

Thank you man!

I really appreciate your invaluable help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

771 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

15 Experts available now in Live!

Get 1:1 Help Now