Solved

Positioning in html/css

Posted on 2011-02-18
4
238 Views
Last Modified: 2012-05-11
hi

in css i have a division tag that can vary in size(accepts input dynamically).

now i want the outside division tag to also expand according to the inner division tag.

for example:

<div id="body">
<div id="content1"></div>
<div id="content2"></div>
</div>





now if the height of the content1 division tag expands(by giving height as auto) i want content2 to go down according to the height of content1 and also the body division tag to expand according to the height of content1.


Thanks in advance.
0
Comment
Question by:manikandan689
  • 2
  • 2
4 Comments
 

Author Comment

by:manikandan689
ID: 34927088
Problem in positioning of html-css
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 34927304
try this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<style>
		#body
		{
			min-height:100px;
			height:auto;
			width:200px;
		}
		#content1, #content2
		{
			min-height:50px;
			height:auto;
			border:1px solid red;
			width:200px;
		}
	</style>
</HEAD>

<BODY>
	<div id="body">
		<div id="content1">
			Content 1 <br>
			Content 1 <br>
			Content 1 <br>
		</div>
		<div id="content2">
			Content 2
		</div>
	</div>
</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:manikandan689
ID: 34928281
hi

i need to position the content1 from top 50px(from body division tag)
 and content 2 from bottom 0px(from body division tag)
and do the previously mentioned functionalities

i.e
if the height of the content1 division tag expands(by giving height as auto) i want content2 to go down according to the height of content1 and also the body division tag to expand according to the height of content1.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34928338
then try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<style>
		#body
		{
			min-height:100px;
			height:auto;
			width:200px;
		}
		#content1
		{
			min-height:50px;
			height:auto;
			border:1px solid red;
			width:200px;
			position:absolute;
			top:50px;
		}
		#content2
		{
			position:absolute;
			height:auto;
			bottom:0px;
			border:1px solid red;
			width:200px;
		}
	</style>
</HEAD>

<BODY>
	<div id="body">
		<div id="content1">
			Content 1 <br>
			Content 1 <br>
			Content 1 <br>
		</div>
		<div id="content2">
			Content 2
		</div>
	</div>
</BODY>
</HTML>

Open in new window

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

896 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

16 Experts available now in Live!

Get 1:1 Help Now