Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-15-2012, 12:33 AM   PM User | #1
jamez14
New to the CF scene

 
Join Date: Jan 2012
Location: Akron, Ohio
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jamez14 is an unknown quantity at this point
Trouble with DIV positioning for CSS layout

So I just started working on my first complete website in a couple years and needless to say i'm behind the times in regards to layouts. I want to use CSS, more specifically DIVs to layout my site. I created a background in Photoshop that will serve as a guide for where I want the various boxes/text.

I've done extensive searching and reading on the different kinds of positioning you can do with DIVs. Whether it be absolute or relative or float. But I have yet to figure out the proper way to code in the various DIVs so that they remain in the same spot no matter the resolution of the screen or if someone resizes the window. I just want to be able to tell them where I want them and not have to worry about them moving. The way I have it coded now, the DIV moves around when I resize the window - something I don't want.

Any help would be greatly appreciated! Like I said I'm just getting back on my feet when it comes to HTML/CSS and i'm a bit rusty. Thanks!!


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>

<style type="text/css">

body {
	font-family: 'Lato', sans-serif;
	margin: 0;
	background: #0C0 url(landscaping1.jpg) no-repeat center top;
	overflow:auto
}

#leftcontent
{
border:1px solid #a1a1a1;
padding:10px 40px; 
background:#dddddd;
width:300px;
height:300px;
border-radius:12px;
-moz-border-radius:25px; /* Firefox 3.6 and earlier */
box-shadow: 10px 10px 5px #888888;
float:left;
position:relative;
top:450px;
left:80px;
}

</style>
<title>Mueller Lawn and Lanscape 2012</title>
</head>

<body>

<div id="leftcontent">
Some text goes here. 
</div>

</body>
</html>
Also, here is what the site looks like with the above code. Obviously i'm still working on the visual aspects of the site, so disregard that part for now.

Last edited by jamez14; 01-15-2012 at 12:38 AM..
jamez14 is offline   Reply With Quote
Old 01-15-2012, 12:53 AM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello jamez14,
A couple quick comments on your CSS -
Code:
body {
	font-family: 'Lato', sans-serif;
	margin: 0;
	background: #0C0 url(landscaping1.jpg) no-repeat center top;
	overflow:auto /*what is it you're trying to do with this?*/
}
#leftcontent {
	border:1px solid #a1a1a1;
	padding:10px 40px;
	background:#dddddd;
	width:300px;
	height:300px;
	border-radius:12px;
	-moz-border-radius:25px; /* Firefox 3.6 and earlier */
	box-shadow: 10px 10px 5px #888888;
	float:left; /*it's float or positioning... not both, though it can be float and relative positioning*/
	position:relative;
	top:450px;
	left:80px;
}
Maybe this link will help you a bit - http://www.barelyfitz.com/screencast...s/positioning/
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
jamez14 (01-15-2012)
Old 01-15-2012, 01:01 AM   PM User | #3
jamez14
New to the CF scene

 
Join Date: Jan 2012
Location: Akron, Ohio
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jamez14 is an unknown quantity at this point
I believe I accidentally put that overflow in there and forgot to take it out.

And I've actually looked at that exact same link you posted when trying to figure out all this positioning stuff. I've tried numerous different things in hopes of finding what I need and still can't figure out how to get my DIVs to remain in one place.

Thanks for your help though with my CSS!!
jamez14 is offline   Reply With Quote
Old 01-15-2012, 01:06 AM   PM User | #4
jamez14
New to the CF scene

 
Join Date: Jan 2012
Location: Akron, Ohio
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jamez14 is an unknown quantity at this point
Basically I want the DIV to "disappear" and force you to scroll to find it if you were to resize the window. Obviously I don't plan on users actually having to do this, unless they have an extremely small resolution.
jamez14 is offline   Reply With Quote
Reply

Bookmarks

Tags
css, div, html, positioning

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:10 AM.


Advertisement
Log in to turn off these ads.