Solved

Two DIV tags in one centred DIV tag

Posted on 2011-02-14
3
304 Views
Last Modified: 2012-05-11
Hi all,

Using css I need to have a DIV tag with a width of 900px centred on a webpage.

Inside that tag, I need to have two other DIV tags that share the space equally, 450px each, one aligned to the left, one to the right.

Any help is appreciated.

Thanks.

resourcesys.
0
Comment
Question by:resourcesys
3 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 34886879
try this one

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<style>
		.centerDiv
		{
			width:902px;
			height:450px;
			margin:40;
			border-width:1px;
			border-style:solid;
		}
		.leftDiv
		{
			width:450px;
			height:450px;
			background-color:pink;
			display:inline;
		}
		.rightDiv
		{
			width:450px;
			height:450px;
			background-color:blue;
			display:inline;
		}
	</style>
</HEAD>

<BODY>
	<div class="centerDiv">
		<div class="leftDiv"></div>
		<div class="rightDiv"></div>
	</div>
</BODY>
</HTML>

Open in new window

0
 
LVL 4

Assisted Solution

by:DangerousJeff
DangerousJeff earned 250 total points
ID: 34886927
Pretty similar

<html>
<head>

<style>

#container {
	
	width: 900px;
	margin: 0 auto;

}
#leftcol {
	width: 450px;
	float: left;


}
#rightcol {
	width: 450px;
	float: left;

}
</style>
</head>
<body>

<div id="container">
<div id="leftcol">
<h1>Left side</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.</p>
</div>
<div id="rightcol">
<h1>Right side</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.</p>
</div>
</div>

</body>
</html>

Open in new window

0
 

Author Closing Comment

by:resourcesys
ID: 34886982
Thanks for both replies.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
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)
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…

707 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

11 Experts available now in Live!

Get 1:1 Help Now