TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-23-2008, 09:38 PM   #1 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default DIV side by side

I'm finding myself use negative numbers for my 2nd DIV if I need it to be set next to another DIV. I'm currently using relative positions.

Is there a way to put DIVs next to each other without making a cluster code?
9three is offline  
Reply With Quote
Old 12-23-2008, 10:21 PM   #2 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

.divclass { width:200px; float:left; display:block; }

then after all the divs you will need one more div with

<div style="clear:both"></div>

that should work.
CoryMathews is offline  
Reply With Quote
The Following User Says Thank You to CoryMathews For This Useful Post:
9three (12-24-2008)
Old 12-24-2008, 12:32 AM   #3 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

works like a charm :)
9three is offline  
Reply With Quote
Old 12-27-2008, 02:41 AM   #4 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

hm this wont work if i need more DIVs under each other. they tend to sorta spaz out
9three is offline  
Reply With Quote
Old 12-27-2008, 06:59 AM   #5 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

Set a height then. That will fix it you also might want to add overflow:hidden;

so the css will be

.divclass { width:200px; float:left; display:block; height:20px; overflow:hidden; }
CoryMathews is offline  
Reply With Quote
Old 12-27-2008, 06:21 PM   #6 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

hm that didnt do anything. What I'm looking for is something like this:

Header1--------------------Header2
Content1-------------------Content2

The problem though, with your code, whats happening in the following:

Header1 Content1-----------Header2
-----------------------Content2

I already added the overflow and height but nothing :/

EDIT: I just added the overflow to content1 and content2 with a set height and it fixed content2 to be right under header2 but content1 is still not positioned where it suppose to be. It should be under header1 but its right on the top margin, and right next to header1. So this is what it looks like now:

Header1 Content1------------Header2
-----------------------------------Content2
9three is offline  
Reply With Quote
Old 12-27-2008, 08:06 PM   #7 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

Can you post your actual code for me.
CoryMathews is offline  
Reply With Quote
Old 12-27-2008, 08:26 PM   #8 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

Sure

Code:
body {
  font-family: Verdana, Helvetica, Arial, Tahoma, sans-serif;
  font-size: 10px;
  color: #FFFFFF;
  margin: 0px;
  padding: 0px;
  background: #1c2932 url(../images/bg_nav.jpg) repeat-x left top;
}

/* Layout design */

#wrapper {
  position: relative;
  margin: 0 auto;
  padding: 0px;
  width: 780px;
  height: 0px;

}

hr {
  border: 0;
  color: #9E9E9E;
  background-color: #9E9E9E;
  height: 1px;
  width: 100%;
}

ul {
  list-style: none;
  margin: 0px;
  padding: 0px;
}
li {
  list-style-type: none;
  list-style-position: outside;
  padding: 0px;
  margin: 0px;
  height: 14px;
  width: 100%;

}

/* Font styles */

.navtxt {
  padding-top: 10px;
  font-weight: bold;
}

.attention {
  font-weight: bold;
}

/* Link Styles */

a:link, a:active {
  color: #FFFFFF;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.nav {
  display: block;
  background: #142129;
  padding: 0px;
  margin-top: 1px;
  padding-top: 2px;
}
/* Main DIVs */

.navleft { 
 width: 100px; 
 float: left; 
 display: block;
 height: 50px;
 overflow: hidden;
}

.navright {
 width: 150px; 
 float: right; 
 display: block;
 height: 50px;
 overflow: hidden;
}

.contentleft {
 top: 0px;
 margin: 0px;
 width: 500px; 
 float: left; 
 display: block;
 background: #FFFFFF;
 color: #000000;
 overflow: hidden;
 height: 100px;
}

.contentright {
 top: 0px;
 left: 0px;
 margin: 0px;
 width: 141px; 
 float: right; 
 display: block;
 color: #FFFFFF;
 overflow: hidden;
 height: 400px;
}
The code you gave me is under /* Main DIVs */ and the classes are navleft, navright, contentleft and contentright

hm I'm wondering, maybe, its not working because I dont have wrappers for the actual content. Maybe it will work if I wrap navleft and navright together and contentleft and contentright together? that way it doesn't conflict with any other DIVs but the ones inside the wrapper?
9three is offline  
Reply With Quote
Old 12-27-2008, 08:37 PM   #9 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

HTML Code:

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" />
<title></title>
<link href="styles/default.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
    <div class="topnav">
    <div class="navleft" align="left">
    <div class="navtxt">Title.com</div>
    </div>
    <div class="navright">
    <div class="navtxt" align="right">
    <a href="#" class="navlink">Home</a> | <a href="#">Forums</a> | <a href="#">Contact</a></div>
    </div>
    </div>
  <div class="contentleft">
Hello
  </div>
  <div class="contentright">
  <div class="attention">Section1</div>
  <hr />
  <ul>
  <li><a href="#" class="nav">HTML & CSS</a></li>
  <li><a href="#" class="nav">PHP & MYSQL</a></li>
  </ul>
  <p></p>
  <ul>
  <li class="attention">Section2</li>
  <li><hr /></li>
  <li>HTML & CSS</li>
  <li>PHP & MYSQL</li>
  </ul>
  </div>
  <div style="clear:both"></div>
</div>
</body>
</html>
9three is offline  
Reply With Quote
Old 12-28-2008, 05:41 PM   #10 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

The problem is not a really a css or an html problem but a problem with the sizes you picked.

.navleft { width:100px; float:left; display:block; height:50px; overflow:hidden; }
.navright { width:150px; float:right; display:block; height:50px; overflow:hidden; }
.contentleft { top:0; margin:0; width:500px; float:left; display:block; background:#FFF; color: #000; overflow: hidden; height:100px; }
.contentright { top:0; left:0; margin:0; width:141px; float:right; display:block; color:#FFF; overflow:hidden; height:400px; }

change that to

.navleft { width:500px; float:left; display:block; height:50px; overflow:hidden; }
.navright { width:150px; float:right; display:block; height:50px; overflow:hidden; }
.contentleft { top:0; margin:0; width:500px; float:left; display:block; background:#FFF; color: #000; overflow: hidden; height:500px; }
.contentright { top:0; left:0; margin:0; width:150px; float:right; display:block; color:#FFF; overflow:hidden; height:400px; }

that should clean it up. You basically just had your wrapper to large and your contents to small.
CoryMathews is offline  
Reply With Quote
Old 12-28-2008, 06:28 PM   #11 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

yyesss it worked. thanks, i didnt catch that earlier
9three is offline  
Reply With Quote
Old 02-03-2009, 06:12 PM   #12 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

Cory,

I have a new CSS problem. Remember how we set the tables to be all the same height? Well now the tables are going to change a little. They need to stack under each other with a padding of about 10-20 pixels. The problem is, when I use your code, the heights on all of them are the same, thus creating a huge gap in between the tables.

It's going to be 3 tables in one row, and 3 tables in the second row. With different heights on each table. In essence they wont be straightly aligned, some will be higher than others.

Or would I just have to force the tables to move the way I want them to?

I hope you understand me.
9three is offline  
Reply With Quote
Old 02-06-2009, 05:26 PM   #13 (permalink)
The Contributor
 
Join Date: Apr 2005
Location: Kent, UK
Posts: 54
Thanks: 0
Dr John is on a distinguished road
Default

This would be much easier if you posted a link, so we could see what is going on.

If you set the height of a class of div and then put each table in its own div that might help you, but without a site to play with and edit, it's tricky to see what your problem is.

PS you have some totally unnecessary code there, where you tell a div to use display:block; because a div is a block level element by definition.
__________________
www.kidneydialysis.org.uk
Dr John is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Side Image Resizing and Compression... d4v1d Javascript, AJAX, E4X 1 07-07-2009 09:34 AM
FFmpeg server side sarmenhb General 5 12-13-2008 01:53 AM


All times are GMT. The time now is 06:06 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design