Solved

Don't understand this style

Posted on 2011-03-22
10
207 Views
Last Modified: 2012-05-11
I'm working with this webpage and I don't understand the style for this tag.

This is the style for the main <div> tag (that holds other <div> tags)
<BODY>
<DIV id=main>...........</DIV></BODY>  :

     #main {POSITION: absolute; WIDTH: 950px; MARGIN-LEFT: -475px; LEFT: 50%}


I don't understand the "-475px; LEFT: 50%" part.

It displays with no problems in the browser, but is it ok to use this style for a webpage?


Other styles used for the page:
BODY {MARGIN: 0px;}
HTML {BACKGROUND-IMAGE: url(images/GT-3000x1BG_lt_grey3.gif); BACKGROUND-REPEAT: repeat-y; BACKGROUND-POSITION: center 50%}

0
Comment
Question by:MikeMCSD
  • 5
  • 5
10 Comments
 
LVL 7

Expert Comment

by:nbove
ID: 35192055
The "MARGIN-LEFT:-475px;" part will shift the div to the left 475 pixels.  And the "LEFT:50%" part will make left section of the div begin at 50% at the midpoint of it's parent.  The combination of the two will make the div show up 475 pixels to the left of the midpoint of the screen, essentially centering the div.
0
 
LVL 16

Author Comment

by:MikeMCSD
ID: 35193918
thanks . .

but why do that to center it?  Aren't there other ways, or better ways to do it?
0
 
LVL 7

Expert Comment

by:nbove
ID: 35193983
As for why certain programmers code things in certain ways, I have given up trying to understand such things.  Yes, there are better ways to center a block.  If I were writing the style for the above block I would have written it as:

#main {POSITION: relative; WIDTH: 950px; MARGIN-LEFT: auto; MARGIN-RIGHT: auto}

0
 
LVL 16

Author Comment

by:MikeMCSD
ID: 35194092
I miss laying out pages with <tables>.
This <div> thing is confusing the hell out of me.
0
 
LVL 7

Expert Comment

by:nbove
ID: 35194109
Ultimately, it is up to you to lay your page out in whatever manner makes the most sense to you.  There are advantages to using DIV tags and CSS to control the style of your site, but if it makes the site confusing and unmaintainable for you, then I would say that the benefits do not outweight the drawbacks for you.  Use whatever method works best for you and makes a clean page that is easy for you maintain.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Author Comment

by:MikeMCSD
ID: 35194136
But <div>'s are suppose to be better for SEO and page load speed.
Then you have to deal with the IE6 and IE7 problems.
I guess I'll just have to put more study time into it.

0
 
LVL 7

Expert Comment

by:nbove
ID: 35194226
You are correct.  Incidentally, if your question has been answered, please mark this question as answered.
0
 
LVL 16

Accepted Solution

by:
MikeMCSD earned 0 total points
ID: 35281603
I tried your style and the original one in IE5 and the original one was centered
and yours didn't display right.
I'm beginning to think there is some real reason why they used that style.
Maybe it works best for all browsers.
If it wasn't for all this browser compatility nonsense, CSS would'nt be so bad.
It will take another few years before this problem goes away.
0
 
LVL 7

Expert Comment

by:nbove
ID: 35287261
It appears that your original question has been resolved.  If so, please mark this question as resolved.
0
 
LVL 16

Author Closing Comment

by:MikeMCSD
ID: 35321847
Need someone who is really a pro at CCS to give the correct insight into this question.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change color of modular 8 21
How to change pointer icon to hand icon on mouseover 2 17
Form Submit falis 6 25
javascript date picker in php while loop 5 20
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Find out what you should include to make the best professional email signature for your organization.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now