HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Floating?
Post new topic   Reply to topic    HTML Help Forum Index -> CSS
View previous topic :: View next topic  
Author Message
Liana



Joined: 12 Feb 2006
Posts: 6

PostPosted: Tue Feb 14, 2006 6:35 am     Floating? Reply with quote

This is me trying to run before I can walk again, as only a week or two ago I'd never heard of CSS (I just about knew what HTML was Wink), but I'd really appreciate it if someone could be so kind as to give me some advice without laughing too hard at my pathetic attempt (see below).

I'm trying to make a box with 3 boxes sitting in side of it - 2 little ones over to the left on top of each other, and one long one over to the right next to them.

It looks fine in IE6 when the browser window is fully open, but when I shrink the window it's a disaster! Ditto if I put a DTD in - disaster. I'm guessing it could be a bit of a mess in other browsers too.

If it's possible to give me some guidance on how to solve this problem I'd be really grateful.

I feel a bit guilty asking for help as I'm no where near a standard yet where I'm going to be able to contribute to this forum!

Code:

<html>
<head>

<style>
body
  {background-color: #000033;
   margin-top: 0px;
   margin-bottom: 0px;
   border: 0px;
   padding: 0px;}
div.main
  {position: relative;
   top: 5%;
   margin-left: 34%;
   margin-right: 34%;
   height: 75%;
   border: 3px solid red;
   background-color: black;}
div.box1, .box2,
  {background-colour: black;
   margin-top: 15px;
   margin-left: 8px;
   margin-right: 10px;
   border: 3px solid red;
   width: 43%;}
div.box1
  {height: 18%;
   float: left;}
div.box2
  {height: 50%;
   float: right;}
</style>

</head>

<body>
   <div class="main">
   <div class="box1"></div>
   <div class="box2"></div>
   <div class="box1"</div>
   </div>
</body>

</html>


Thanks for reading

L
Corey Bryant



Joined: 15 May 2004
Posts: 8154
Location: Castle Rock CO USA

PostPosted: Tue Feb 14, 2006 10:49 am     Reply with quote

Thanks for the code, I think I understand what you are trying to do,
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<style>
body
  {background-color: #000033;
   margin-top: 0px;
   margin-bottom: 0px;
   border: 0px;
   padding: 0px;}
div.main
  {position: relative;
   top: 5%;
   margin-left: 34%;
   margin-right: 34%;
   height: 75%;
   border: 3px solid red;
   background-color: black;}
div.box1, .box2
  {background-colour: black;
   margin-top: 15px;
   margin-left: 8px;
   margin-right: 10px;
   border: 3px solid red;
   width: 43%;}
div.box1
  {height: 18%;
   float: left;}
div.box2
  {height: 50%;
   float: right;
   clear: right}
</style>

</head>

<body>
   <div class="main">
   <div class="box1"></div>
   <div class="box2"></div>
   <div class="box1"></div>
   </div>
</body>

</html>
and see if that helps.

_________________
Corey
Loud Commerce | LoudHost | Toll Free Solutions
Liana



Joined: 12 Feb 2006
Posts: 6

PostPosted: Tue Feb 14, 2006 11:05 am     Reply with quote

Hey Corey

Thanks so much for taking the time to look at it for me.

If I take the DTD out of yours it is a big improvement on mine - in that I can shrink the browser window without it going insane. But with the DTD in it still doesn't work (though it's not quite as bad - the boxes just get all squished up the top of the window really tiny).

Tis weird. I know not what to do :/
Corey Bryant



Joined: 15 May 2004
Posts: 8154
Location: Castle Rock CO USA

PostPosted: Tue Feb 14, 2006 11:11 am     Reply with quote

Well keep in mind that you are only using about 32% of the browser space - so that is not a lot at all

_________________
Corey
Loud Commerce | LoudHost | Toll Free Solutions
Liana



Joined: 12 Feb 2006
Posts: 6

PostPosted: Tue Feb 14, 2006 5:15 pm     Reply with quote

Ok, thanks.

I've changed it now so that the main box is a fixed width and this seems to work a lot better. I changed the foats a bit as well.

Code:


<html>
<head>

<style>
body
  {background-color: #000033;
   border: 0px;
   padding: 0px;}
div.main
  {position: absolute;
   top: 15px;
   left: 50%;
   margin-left: -150px;
   width: 310px;
   height: 500px;
   background-color: red;
   border: 3px solid white;}
div.left
  {float: left;}
div.box1
  {background-colour: black;
   margin-top: 8px;
   border: 3px solid white;
   height: 100px;
   width: 134px;
   margin-left: 10px;}
div.box2
  {background-colour: black;
   margin-top: 8px;
   border: 3px solid white;
   width: 134px;
   height: 300px;
   margin-left: 10px;
   float: left;}
</style>

</head>

<body>
   <div class="main">
   <div class="left">
      <div class="box1"></div>
      <div class="box1"></div>
   </div>
   <div class="box2"></div>
   </div>
</body>

</html>
Corey Bryant



Joined: 15 May 2004
Posts: 8154
Location: Castle Rock CO USA

PostPosted: Tue Feb 14, 2006 5:18 pm     Reply with quote

Good, I usually do not use percentages for because of this issue

_________________
Corey
Loud Commerce | LoudHost | Toll Free Solutions
Liana



Joined: 12 Feb 2006
Posts: 6

PostPosted: Tue Feb 14, 2006 5:30 pm     Reply with quote

Ok yes, I think I'm starting to see how they can be problematic!

L
errorlevel_03



Joined: 11 Feb 2006
Posts: 27

PostPosted: Tue Feb 14, 2006 6:41 pm     Reply with quote

Why not just use a table for this?
Corey Bryant



Joined: 15 May 2004
Posts: 8154
Location: Castle Rock CO USA

PostPosted: Tue Feb 14, 2006 7:08 pm     Reply with quote

Because tables are not meant for a site layout - they are meant for tabular data

_________________
Corey
Loud Commerce | LoudHost | Toll Free Solutions
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> CSS All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial