LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-03-2008, 06:40 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
css div - fixed size + center placement


Hi,

I am doing my first website in many years and I am trying to embrace this new "div"-thing that seems to be the new hot thing when it comes to layout. However, it is extremely different from the old tables that I am used to.

So what I am trying to do is that I want to divide the site in three columns: 2 margins on each side and a fixed size (800 pixels) column in the middle.

The key is that I want to just make the site in 800 px and be done with it, that way I don't have to care about different screen resolutions. It's a quick and dirty way, but it's fine for me.

Anyone know how to help me?

Thanks.
 
Old 12-04-2008, 03:06 PM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
The CSS Code (main.css):
Code:
body {
   background: rgb(150,150,150);
}

#container {
   width: 800px;
   height: 550px;
   border: 2px solid rgb(50,50,50);
   background: rgb(255,255,255);
   margin: 0px auto;
}
The HTML Code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3c.org/TR/html4//strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="author" content="Disillusionist">
    <link rel="stylesheet" type="text/css" href="main.css">
  </head>
  <body>
    <div id="container">
      Place the rest here...
    </div>
  </body>
</html>
 
Old 12-04-2008, 05:57 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
A <div> is hardly a "hot new thing"!!!

<div> and css are different concepts--you can have one without the other.

The book which got me "over the hump" with all this was "Spring into CSS and HTML" by Molly Holzschlag. Will be at most large bookstores or Amazon
 
Old 12-05-2008, 01:45 AM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
I find w3schools.com to be one of the best online references for learning about css, html, and many more.

Pix, I suppose "new" is relative to how long ago the OP last wrote a web page.

Last edited by Disillusionist; 12-05-2008 at 01:47 AM.
 
Old 12-05-2008, 07:48 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I thought that <div> and <span> had been part of html from the beginning....

I am not a programmer or a web designer and I have surely undersampled the available literature....

Ditto w3schools...The thing I like about the Holzschlag is the way she leads you thru a simple web page---it just made it "click" for me.
 
Old 12-05-2008, 11:55 AM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
They were (from HTML 2.0)

However, in the past most people (miss)used tables to set the layout of a web page.

It is only really in the last five years that people have taken to using <DIV> tags to segment the data and apply CSS styles to the different sections.

Therefore the "New" is more that people are now aware that the feature is there and are using it.
 
Old 12-05-2008, 05:54 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
And then of course there are ((shudder)) FRAMES!!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS div layout Chronothread Programming 1 09-29-2008 06:00 PM
How do you control size and placement of widgets in table under gtk davimint Programming 1 09-10-2008 12:48 PM
simplest way to center a <div> on the screen via css tanoatlq Programming 4 06-02-2008 02:50 AM
css/html wtf? extra space below div nkoplm Programming 1 06-27-2007 03:31 PM
Trying to create overlapping CSS div boxes. rose_bud4201 Programming 2 05-13-2007 02:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration