Current location: Hot Scripts Forums » General Web Coding » CSS » Div aligning problem


Div aligning problem

Reply
  #1 (permalink)  
Old 01-17-09, 07:11 PM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 143
Thanks: 5
Thanked 0 Times in 0 Posts
Div aligning problem

Here is my site:

www.shuffledrive.co.uk/mel

I have div aligning problems in IE 7 the main content sits underneath the sidebars. But in Firefox 3 it is fine.

Now I'm using a php script the main content is defined by any div it just shows up eg. defined by body css (if you know what I mean). How come I'm having positioning problems in IE7 but not in Firefox 3?
How do I fix it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-18-09, 01:11 PM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 143
Thanks: 5
Thanked 0 Times in 0 Posts
can anyone help with this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-18-09, 02:21 PM
groone groone is offline
New Member
 
Join Date: Jan 2009
Location: Mobile, ALabama
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Yea, IE handles things a bit differently then Firefox Lets imagine that this is the edge of your div |

padding: 5px

Firefox measures like this

<----5px-----|

IE measures like this

|<----5x------

As you see, this can throw everything askew. IE will not fix this so the best thing to do would be to create a style entry that only IE can read

Do your style like normal
Code:
<style type="text/css">
  .element{
     padding: 5px;
  }
</style>
And then do a style for IE like this
Code:
<!--[if IE]>
<style type="text/css">
  .element{
     padding: 0px;
     margin-left: 5px;
  }
</style>
<![endif]-->
For IE your css element will be rewritten with the new settings.

If you are using a style sheet then you can do the same thing
Code:
<link href="http://www.yoururl.com/css/firefox.css" rel="stylesheet" type="text/css" >
<!--[if IE]>
<link href="http://www.yoururl.com/css/ie.css" rel="stylesheet" type="text/css" >
<![endif]-->
You can write a separate style sheet for IE and only IE will read it and still maintain the settings for Firefox
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-18-09, 03:10 PM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 143
Thanks: 5
Thanked 0 Times in 0 Posts
Thank you so much, but /i've rewitten it and it still appears to be the same in IE :S
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-18-09, 03:20 PM
groone groone is offline
New Member
 
Join Date: Jan 2009
Location: Mobile, ALabama
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
You have to make sure that you use the same element name and clear out any options that are listed in it.

if you use Firefox, download the Firebug addon...there might be something else that is causing the misalignment.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-19-09, 03:26 PM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 143
Thanks: 5
Thanked 0 Times in 0 Posts
Can anyone else help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-31-09, 01:50 AM
ajit22 ajit22 is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
This would normally be done using floats (unless you want to go down the route of absolute positioning). The 'reactiveness" is one of the advantages of using floats, combined with clear.
For example:
Code:
#div1 { float: left; }
#div2 { float: left; }

<div id="div1">Hello</div>
<div id="div2">World</div>
hope it is exactly as you looking for.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 02-01-09, 03:25 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Your display is basically a three column display.
So you need to create three columns.
You could easily do that with a table with one row and three cells.
Or you could use three div's floated left.

I decided to use three div's.

This is the simplest way I could figure to set it up.
Besides changing your layout, I only made a few small changes.
And one big change ( I removed most of the black space on either side of your logo image and put it in an image element instead of the div's background).
That gave me a lot more control over it.

Here is the code:
HTML Code:
<html>
<head>
<style>
body {
margin:0px;
background-color:#101010;
color:#ffffff;
font-family: Tahoma;
font-size: 14px;
}
#column_1 {
width:26%;
float:left;
}
#column_2 {
width:47%;
float:left;
text-align:center;
}
#column_3 {
width:26%;
float:left;
}
#nav {
background:#81C524 url('http://www.shuffledrive.co.uk/mel/images/nav456.gif') repeat-x;
height:40px; /*The height of the menu */
line-height:40px; /*The line-height property sets the distance between lines.*/
text-decoration:none;
}
#nav ul {
list-style:none;
margin:0;
padding:0 0 0 20px;
}
#nav ul li {
display:inline;
}
#nav ul li a {
padding:0 12px;
}
a:visited {
   color:#ffffff;
   text-decoration:none;
}
a:link {
   color:#ffffff;
   text-decoration:none;
}
a:hover {
   color:#a0a0a0;
   text-decoration:none;
}
a:active {
   color:#ffffff;
   text-decoration:none;
}
.sidebar_left {
width:201px;
margin-left:30px;
background: url('http://www.shuffledrive.co.uk/mel/images/mid.png') repeat-y;
}
.sidebar_right {
width:201px;
margin-left:30px;
background: url('http://www.shuffledrive.co.uk/mel/images/mid.png') repeat-y;
}
.sidebartext {
text-align:center;
}
.sidebar_bottom {
width: 201px;
margin-left:30px;
}
.offers {
display:block;
}
#footer{
clear:both;
height:40px;
background: #81C524 url('http://www.shuffledrive.co.uk/mel/images/nav456.gif') repeat-x;
}
</style>
</head>
<body>
<div class="sidebartext">
 <img src="images/logo.jpg" />
</div>
<div id="nav">
 <ul>
  <li><a href="index.php">Home</a></li>
  <li><a href="register.php">Register</a></li>
  <li><a href="login.php">Login</a></li>
  <li><a href="members.php?offers=42">Members</a></li>
  <li><a href="members.php?offers=42">Easy Cash</a></li>
  <li><a href="#">Forum</a></li>
  <li><a href="terms.php">T&C's</a></li>
  <li><a href="contact.php">Contact Us</a></li>
 </ul>
</div>
<div id="column_1">
 <div class="sidebar_left">
  <img src="http://www.shuffledrive.co.uk/mel/images/cat.png" alt="categories" border="0"/>
  <div class="sidebartext">
   <a class="offers" href="offers.php?offers=42"><b>Easy Cash</b></a>
   <a class="offers" href="offers.php?offers=26">Accommodation</a>
   <a class="offers" href="offers.php?offers=27">Adult</a>
   <a class="offers" href="offers.php?offers=30">Arts and Crafts</a>
   <a class="offers" href="offers.php?offers=31">Books and Catalogues</a>
   <a class="offers" href="offers.php?offers=32">Business Services</a>
   <a class="offers" href="offers.php?offers=33">Business Supplies</a>
   <a class="offers" href="offers.php?offers=25">Charities</a>
   <a class="offers" href="offers.php?offers=24">Children</a>
   <a class="offers" href="offers.php?offers=23">Clothing</a>
   <a class="offers" href="offers.php?offers=22">Competitions</a>
   <a class="offers" href="offers.php?offers=21">Computers</a>
   <a class="offers" href="offers.php?offers=16">Designer Clothing</a>
   <a class="offers" href="offers.php?offers=17">Education</a>
   <a class="offers" href="offers.php?offers=18">Electrical Goods</a>
   <a class="offers" href="offers.php?offers=19">Fashion</a>
   <a class="offers" href="offers.php?offers=20">Finance and Legal</a>
   <a class="offers" href="offers.php?offers=15">Food and Drink </a>
   <a class="offers" href="offers.php?offers=7">Freebies</a>
   <a class="offers" href="offers.php?offers=6">Gadgets and Other Gifts</a>
   <a class="offers" href="offers.php?offers=14">Gambling</a>
   <a class="offers" href="offers.php?offers=13">Gaming</a>
   <a class="offers" href="offers.php?offers=11">Gifts</a>
   <a class="offers" href="offers.php?offers=12">Health and Beauty</a>
   <a class="offers" href="offers.php?offers=41">Holidays</a>
   <a class="offers" href="offers.php?offers=5">Home and Garden</a>
   <a class="offers" href="offers.php?offers=40">Loans</a>
   <a class="offers" href="offers.php?offers=44">Magazines</a>
   <a class="offers" href="offers.php?offers=10">Mobiles Phones</a>
   <a class="offers" href="offers.php?offers=9">Motoring</a>
   <a class="offers" href="offers.php?offers=8">Music and Video</a>
   <a class="offers" href="offers.php?offers=38">Online Services</a>
   <a class="offers" href="offers.php?offers=34">Pets</a>
   <a class="offers" href="offers.php?offers=43">Posters & Prints</a>
   <a class="offers" href="offers.php?offers=35">Sports and Fitness</a>
   <a class="offers" href="offers.php?offers=39">Sports Equipment</a>
   <a class="offers" href="offers.php?offers=36">Tickets and Events</a>
   <a class="offers" href="offers.php?offers=47">Toy Shops</a>
   <a class="offers" href="offers.php?offers=37">Travel</a>
  </div>
 </div>
 <div class="sidebar_bottom">
  <img src="http://www.shuffledrive.co.uk/mel/images/bott.png" alt="categories" />
 </div>
</div>
<div id="column_2">
 <img src="http://www.shuffledrive.co.uk/mel/images/frontpage.jpg" alt="image" />
</div>
<div id="column_3">
 <div class="sidebar_right">
  <img src="http://www.shuffledrive.co.uk/mel/images/member.png" alt="categories" />
  <div class="sidebartext">
   <form method="post" action="">
     Username: <br><input type="text" name="username"><br>
     Password: <br><input type="password" name="password"><br>
     <input type="submit" value="Login" name="login">
    </form>
  </div>
  <img src="http://www.shuffledrive.co.uk/mel/images/bott.png" alt="categories" />
  <img src="http://www.shuffledrive.co.uk/mel/images/stat.png" alt="categories" />
  <div class="sidebartext">
   <p>Total Users: 14<br>Total Offers: 61<br>Accounts Balance: £31.70</p>
  </div>
  <img src="http://www.shuffledrive.co.uk/mel/images/bott.png" alt="categories" />
 </div>
</div>
<div id="footer"></div>
</body>
</html>
I have attached the edited logo image.
Attached Images
File Type: jpg logo.jpg (10.9 KB, 197 views)
__________________
Jerry Broughton

Last edited by job0107; 02-01-09 at 03:28 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
div problem - expand by content SergiuGothic CSS 2 03-24-09 07:43 AM
Problem Aligning Ads Heidenreich12 CSS 2 12-13-08 03:19 PM
Bottom aligning problem UnrealEd CSS 2 07-18-08 05:21 AM
div and css problem nicpon CSS 5 09-03-06 10:38 PM
CSS Div problem themanmathias CSS 1 09-29-05 09:05 PM


All times are GMT -5. The time now is 12:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.