Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Box in middle of page
Old 02-25-2006, 03:26 PM Box in middle of page
Harvey's Avatar
Super Spam Talker

Posts: 901
Name: Harvey C
Location: Brighton, UK
Trades: 0
I've never really used "tableless CSS", although I've had quite a bit of experience with general CSS & PHP.

For a new site, I'd like to have a box, in the centre of the page. Simple enough, but can't work out how to achieve this!

No more tables & linespaces for me
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Harvey is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-25-2006, 10:36 PM Re: Box in middle of page
Junior Talker

Posts: 4
Trades: 0
Your Q is a bit generalised in nature and it seems like you may have to go way back to the start of it all and learn the basics. But if a box is all you want then try this.
!!!note this is in no way the only way to "put a box in the centre of a page", just thought this may be the closest thing your after.

Code:
<html>

<head>

<title>Box demo</title>

<style type="text/css">

#box {
    position:absolute;
    border:solid black 1px;
    top:25%;
    right:25%;
    bottom:25%;
    left:25%;
    padding:25px;
    margin:25px;
    }

</style>

</head>

<body>

<div id="box">

<p>Here is a box in the middle of the page, even if you adjust the size of your browser.</p>

</div>

</body>

</html>
Good luck and check out some tutes when you get a chance.
Benjo
benjo is offline
Reply With Quote
View Public Profile
 
Old 02-25-2006, 11:35 PM Re: Box in middle of page
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Harvey, there's a lot fo different ways to acheive what you're looking for. Have you started coding the page and if so could you post the code or a link to it? If you haven't started do you have an image that shows the basic look you want?

You'll probably want to use positioning in some way, but the details will depend a little on how you want the rest of the page set up.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 02-26-2006, 04:20 PM Re: Box in middle of page
Harvey's Avatar
Super Spam Talker

Posts: 901
Name: Harvey C
Location: Brighton, UK
Trades: 0
Thanks for your reply.

Yup, of course there are plenty of ways to put a box in the middle of the page - it's just I've never used tableless CSS before and thought it'd be a good time to start.

I've just found a great resource, which tells me exactly what I needed to know. Recommended for those who are also making the leap from tables to tableless CSS!

http://intensivstation.ch/en/templates/
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Harvey; 02-26-2006 at 04:30 PM..
Harvey is offline
Reply With Quote
View Public Profile
 
Old 02-26-2006, 05:30 PM Re: Box in middle of page
Harvey's Avatar
Super Spam Talker

Posts: 901
Name: Harvey C
Location: Brighton, UK
Trades: 0
Alright this is really annoying me now.

I want it to have a width of 720px.
And a height of 420px.

It needs to be centered, so there's equal space on left as there is right. And equal space on top as there is on bottom.

Obviously I want to achieve it using CSS - not something as pointless and dodgy as "<p>&nbsp;</p>"'s!!!

But hey, here's the index page:

HTML Code:
<link href="styles.css" rel="stylesheet" type="text/css">
  <p>&nbsp;</p>
    <p>&nbsp;</p>
  <p>&nbsp;</p>
<div id="content">
  <p>&nbsp;</p>
</div>
And the CSS page:

Code:
body {
  background-color: #E0E9EF;
  font-size: 12px;
  color:#564b47;  
  padding:20px;
  margin:0px;
  text-align: center;
}


#content { 	
  text-align: left;
  vertical-align: middle;	
  margin: 0px auto;
  padding: 0px;
  height: 420px;
  background-color: #ffffff;
  width: 720px;
  border: 1px dashed #564b47;
}
Please help!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Harvey is offline
Reply With Quote
View Public Profile
 
Old 02-27-2006, 02:53 AM Re: Box in middle of page
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
To center things I usually wrap everything to be centered center in a div and then add css like the following:

div#center {width:720px; margin:0 auto}

That will center everthing horizontlly on the page. I've never actually tried to center things vertically, but I think if you add the height and then just have margin: auto instead of margin:0 auto it would work. I think I usually also add position:relative to the div, though I don't think it's necessary. I think I'm also doing other things with it requiring some kind of positioning, but it's something to try if it's not working.

By the way the template resource looks pretty good. Thanks for the link.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by vangogh; 02-27-2006 at 02:55 AM..
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 02-27-2006, 05:13 AM Re: Box in middle of page
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
closest I could get to vertical centring is by using a % for the top margin.

http://www.candsdesign.co.uk/page-te...tre/layout.asp
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-27-2006, 04:06 PM Re: Box in middle of page
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I guess margin: auto doesn't work for vertical centering then. I'll keep the percent option in mind if I need it in the future.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Box in middle of page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32859 seconds with 12 queries