Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need to float these div's?

Status
Not open for further replies.

okpeery

Instructor
Dec 29, 2005
102
US
I tried to get most of my structure in place. I cannot figure out how to get my 450px wide divs to line up next to each other. I thought they would because they reside within a 900px wide container, but they don't sit next to each other. I'm sure I'm miscalculating the box model dimensions.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Your Name and Lesson Plans</title>
<style type="text/css">

body
	{
	background-color:#FFFF66;
	text-align:center;
	margin:0px;
	padding:0px;
	}

h1
	{
	padding-bottom:0px;
	margin-bottom:0px;
	}

h2
	{
	padding-top:0px;
	padding-bottom:0px;
	margin-top:0px;
	margin-bottom:0px;
	}

ul
	{
	padding-top:0px;
	margin-top:0px;
	}

div#container
	{
	width: 905px;
	border:1px solid red;
	text-align:left;
	margin-left:10px;
	}

div#content1
	{
	width: 450px;
	border:1px dotted black;
	}

div#content2
	{
	width: 450px;
	border:1px dotted black;
	}

div#content3
	{
	width: 450px;
	border:1px dotted black;
	}

div#content4
	{
	width: 450px;
	border:1px dotted black;
	}

div#content5
	{
	width: 450px;
	border:1px dotted black;
	}

div#content6
	{
	width: 450px;
	border:1px dotted black;
	}

div#content7
	{
	width: 900px;
	border:3px dashed black;
	}

	
</style>
</head>

<body>
<div id="container">
	<div id="content1">
		<h1>Lesson Plans</h1>
		<ul>
			<li>Mr. Peery</li>
			<li>Tech Lab / Computer Science </li>
			<li>Hill Freedman Middle School</li>
			<li>Weeks of 10/30/2006 and 11/6/2006</li>
		</ul>
		
		<div id="content2">
			<p>Blue Ribbon Logo goes here</p>
			<div id="content3">
				<h1>Objectives</h1>
				<ul>
					<li>Students will</li>
					<li>Students will</li>
					<li>Students will</li>
				</ul>
				<div id="content4">
					<h1>Areas of Interaction</h1>
					<ul>
					<li>Approaches to Learning</li>
					</ul>					
						<div id="content5">
							<h1>Essential Questions</h1>
								<ul>
									<li>ES #1</li>
								</ul>
									<div id="content6">
										<h1>Everyday Materials</h1>
											<ul>
												<li>paper and pencils</li>
												<li>textbooks</li>
											</ul>
												<div id="content7">
													<h1>Learning Activities</h1>
														<h2>Monday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Tuesday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Wednesday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Thursday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Friday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Monday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Tuesday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Wednesday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Thursday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>
														<h2>Friday</h2>
															<ul>
																<li>activity 1</li>
																<li>activity 2</li>
																<li>Homework</li>
															</ul>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>
 
Since DIV's are box elements they dont inherently set themselves side by side like spans. You will need to float them, but there needs to be enough space to accommodate them.

450+450=900px, if you decide to add a border or a margin they wont fit, and will wrapp to the next line. You'll want to have them just a tad smaller than their container. so maybe 430px each in width.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Am I getting crazy or are there two exactly identical questions in two different threads?
 
You are right Vrag, and i missed the fact that the DIV's are all nested inside each other. They would need to be placed like You describe in the other thread here.

And so for simplicity, lets post all answers in the other thread here:

thread215-1295243

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Sorry Vrag, I did start a new post because the other problems were resolved so I wanted to just focus on the div problem. As I said I'm getting rusty since I don't do this often enough. I get the div problems now. Back to the drawing board.

Incidentally if I want to make a for print only version that doesn't print the entire page but just the learning activities div, is this reasonably simple to do?

Thanks again for everyone's help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top