CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 6th, 2003, 02:24 PM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy CSS columns side by side?

Hi all

I'm new to CSS (as of today) and I've decided to try a page layout using only CSS DIVs etc.

My problem is I cannot for the life of me get two DIVs to render beside each other like columns.

Here's my CSS code

Code:
<style type="text/css">
#main {
	float: left;
	position: absolute;
	padding-top: 10%;
	padding-left: 10%;
	}
#cell {
	width: 200px;
	border: 1px solid black;
	}
#rand {
	width: 200px;
	border-left: 1px solid black;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	}
#content {
	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: white;
	cursor: default;
	background: black;
	}
#contentRollOver {
	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: black;
	cursor: default;
	background: white;
	}
#spacer {
	padding: 5px;
	width: 200px;
	height: 19px;
	border: hidden;
	}
#spacerWhite {
	padding: 5px;
	width: 200px;
	height: 19px;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	border-left: 1px solid black;
	background: white;
	}
</style>


and here's the code in my HTML:

Code:
<div id="main">
	<div id="cell"><img src="images/title.gif" name="title" id="title" onMouseOver="MM_swapImage('title','','images/titleinv.gif',1)" onMouseOut="MM_swapImgRestore()"></div>
	<div id="rand"><img src="images/rand1.png"></div>
	<div id="content" align="justify" onMouseOver="this.id='contentRollOver';" onMouseOut="this.id='content';">Hello<br><br>This is where I post my photos, and other assorted tat you may find interesting.<br><br>Thankyou for looking.<br><br>- Laurence</div>
	<div id="spacerWhite" align="center"><a href="mailto:blah@hotmail.com"><img src="images/mail2.gif" border="0"></a></div>
	<div id="cell"><a href="flash.html" target="_blank"><img src="images/oldFlashPage1.gif" name="oldFlash" width="198" height="36" border="0" id="oldFlash" onMouseOver="MM_swapImage('oldFlash','','images/oldFlashPage.gif',1)" onMouseOut="MM_swapImgRestore()"></a></div>
	<div id="spacer"></div>
  <div id="photos"><div id="content" align="center"><img src="images/photosTitle.gif"></div>
	<div id="contentRollOver">Here are some of the photos I've taken since around summer of 2002.  I use the fully manual Praktica L SLR and Olympus D950Z digital cameras primarily, and also sometimes a ****ty APS camera I got for christmas a few years ago.  I scan film photos using an Epson Perfection 1200SCSI, and touch them up when required with Photoshop, then optimise and frame them with Fireworks.</div>
	<div id="content" align="justify">Photo 1</div>
  </div>
	
	
</div>


the two DIVs i want side by side are 'main' and 'photos'. You'll notice I haven't defined photos in the CSS stylesheet; I had originally but because it screwed up so badly I just deleted it and now have one DIV over the other.

Please help me get them side by side! Any help appreciated.

-Laurence

Reply With Quote
  #2  
Old August 6th, 2003, 04:22 PM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,541 kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level)kk5st User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 1 h 27 m 15 sec
Reputation Power: 597
#photos {float: left;}

As long as there is room, they will sit side by side, aligned at the top.

cheers,

gary

Reply With Quote
  #3  
Old August 6th, 2003, 05:19 PM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply, but I'm afraid it doesn't work.

Here's my updated CSS:

Code:
<style type="text/css">
#main {
	float: left;
	position: absolute;
	padding-top: 10%;
	padding-left: 10%;
	width: 210px;
	}
#cell {
	width: 200px;
	border: 1px solid black;
	}
#rand {
	width: 200px;
	border-left: 1px solid black;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	}
#content {
	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: white;
	cursor: default;
	background: black;
	}
#contentRollOver {
	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: black;
	cursor: default;
	background: white;
	}
#spacer {
	padding: 5px;
	width: 200px;
	height: 19px;
	border: hidden;
	}
#spacerWhite {
	padding: 5px;
	width: 200px;
	height: 19px;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	border-left: 1px solid black;
	background: white;
	}
#photos {
float: left;
width: 210px;
}


I thought perhaps #main was filling the width of the page and so forcing #photos below it so I constrained it by making it 210px, but this didn't help.

Any suggestions?

Reply With Quote
  #4  
Old August 6th, 2003, 05:48 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,622 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 2 h 17 m 15 sec
Reputation Power: 548
take photos out of the main div,
and keep the float left,
you probably should get it to work,

btw, you ought to clean up that code
remember that id's are unique can only be assign to one element in the document,
http://www.w3.org/TR/html401/struct/global.html#adef-id

Last edited by Akh : August 6th, 2003 at 05:51 PM.

Reply With Quote
  #5  
Old August 6th, 2003, 08:09 PM
ctstone's Avatar
ctstone ctstone is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 147 ctstone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
by default, a DIV is a block level element. this means it gets rendered on it's own line; everything else is forced to the next line.

you can get around this by forcing the browser to render your DIV as an inline element
Code:
<div style="display: inline">col1</div><div style="display: inline">col2</div>

Reply With Quote
  #6  
Old August 7th, 2003, 07:23 AM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your replies. I managed to get it to work with trial and error insertion of the various styles.

Code:
#main {
	float: left; 
	position: relative;
	padding-top: 30px;
	padding-left: 30px;
	}
#cell {
	width: 200px;
	border: 1px solid black;
	}
#imageCell {

	width: 200px;
	border: 1px solid black;
	}
#rand {

	width: 200px;
	border-left: 1px solid black;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	}
#content {

	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: white;
	cursor: default;
	background: black;
	}
#contentRollOver {

	width: 200px;
	border-top: hidden;
	border-left: 1px solid black;
	border-right: 1px solid black;
	border-bottom: 1px solid black;
	padding: 5px;
	font-family: Arial Narrow, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: black;
	cursor: default;
	background: white;
	}
#spacer {

	padding: 5px;
	width: 200px;
	height: 19px;
	border: hidden;
	}
#spacerWhite {

	padding: 5px;
	width: 200px;
	height: 19px;
	border-top: hidden;
	border-bottom: hidden;
	border-right: 1px solid black;
	border-left: 1px solid black;
	background: white;
	}
#photos {
float: left;
position: relative;
padding-top: 30px;
margin-left: 30px;
}


Akh - why is not not okay to duplicate DIV ids? What if there is content which requires the same style but in a different place on the page, does this mean every instance of it must have its style defined? This would create loads of excess code I would think.

Any tips on how to reduce mine would be good. I tried the shorthand trick (TRBL) but it didn't want to work for me.

My next task is to get the #photos DIV to be hidden when the page loads, and appear when a link is clicked.

Reply With Quote
  #7  
Old August 7th, 2003, 07:33 AM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I understand now. I changed the repeating DIVs to class instead of id, but now my rollovers don't work. I'm using JavaScript rollovers:-

Code:
onMouseOver="this.id='contentRollOver';" 

onMouseOut="this.id='content';"


..but they now don't work because it's classes, not ids. I changed the JavaScript to this.class but that doesn't work.

What's the code i need to i can use both classes *and* have rollovers? It works with multiple IDs, but i'd like to be as compliant as possible.

Thanks

Reply With Quote
  #8  
Old August 7th, 2003, 07:47 AM
jerom jerom is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Posts: 1,014 jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 25 sec
Reputation Power: 9
Use this.className instead of this.id

Hope this helps,
Jeroen

Reply With Quote
  #9  
Old August 7th, 2003, 07:56 AM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
works perfectly, thankyou

Reply With Quote
  #10  
Old August 7th, 2003, 08:10 AM
icy_polecat's Avatar
icy_polecat icy_polecat is offline
Senior Polecat
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Jersey (the original version)
Posts: 210 icy_polecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 57 sec
Reputation Power: 6
Send a message via Yahoo to icy_polecat
Quote:
why is not not okay to duplicate DIV ids


ID's are only meant to be used as unique identifiers of page objects within the DOM. You can't use the same ID for more than one element. It used to be the case that groups of elements could be given the same "name" parameter but this is being deprecated in XHTML 1.1

Quote:
What if there is content which requires the same style but in a different place on the page


Use classes. Add the class parameter to the element ie: class="..." and then add the class to your stylesheet:
.classname
{
Styling goes in here
}

Icy
__________________
Quidquid latine dictum sit, altum viditur.

http://www.XSet.co.uk

Reply With Quote
  #11  
Old August 7th, 2003, 08:18 AM
melatonin melatonin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 13 melatonin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, that's what i did based on the link that AKH posted.

heh i've learned so much in the past day about CSS and whatnot. very cool technology indeed.

Reply With Quote
  #12  
Old August 7th, 2003, 08:22 AM
icy_polecat's Avatar
icy_polecat icy_polecat is offline
Senior Polecat
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Jersey (the original version)
Posts: 210 icy_polecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 57 sec
Reputation Power: 6
Send a message via Yahoo to icy_polecat
Wink

sorry for the duplication of advice - i started typing a reply and then went and has luch - by the time i got back it had bee sorted

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS columns side by side?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |