Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Css Alignment Bug, Moves my page when I click on a link
darran
post Jun 27 2007, 02:15 AM
Post #1


Privileged Member
*********

Group: Members
Posts: 660
Joined: 31-August 06
From: Singapore
Member No.: 29,189



This is a bug I am really confused by and I hope I can get some help over here.

I am in the midst of creating my very own WordPress Theme for my site which involves full styling using CSS. I am moving away from tables.

I have a layout which is 770px in width (fixed), and I want to align it to the center.

Ideally, this is what I put in my CSS.

CODE
#wrapper {
   margin: 0 auto 0 auto;
}


This visually looks fine on my browser at first. But when I click on say, a post permalink which will bring me to the view the entire post. The entire layout shifts to the left by a mere 5px. Can anyone tell me what is going wrong?

If you need to see any code, just make a mention and I will give it to you.
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Jun 27 2007, 02:34 AM
Post #2


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,438
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



I thought aligning center is just
CODE
margin: 0 auto;

this centers from left and right. And to center top and bottom try placing padding instead of margin.
Go to the top of the page
 
+Quote Post
Saint_Michael
post Jun 27 2007, 02:39 AM
Post #3


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,308
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



Hard to say really it could be anything in the code, I would say we would need to see the site and a demo page for people to add something it and see it in action and the CSS code as well. Nothing really comes to mind as to why it would misaligned like that, unless your mixing fixed and liquid width's within your CSS. But thats only a guess without looking at the code and the demo page.
Go to the top of the page
 
+Quote Post
truefusion
post Jun 27 2007, 02:45 AM
Post #4


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,868
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



I don't believe it's due to the CSS since you mention everything works fine until you click a link, and 'cause the CSS provided should work fine. Does this problem occur only when you click a link or have you experienced it with other things? We'll have to be able to view the coding to get down to the problem.
Go to the top of the page
 
+Quote Post
Saint_Michael
post Jun 27 2007, 03:05 AM
Post #5


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,308
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



After doing some research it would seem that trying to align using auto will not work in some browers and so you would have to do something like this

CODE
div#container
{
margin-left: 10%;
margin-right: 10%;
}


but here is a great example of what you want to achieve

http://bluerobot.com/web/css/center1.html

Thee list the code of how to set it up, hopefully that gives you a couple of idea's where to look into solving your problem.
Go to the top of the page
 
+Quote Post
darran
post Jun 27 2007, 05:05 AM
Post #6


Privileged Member
*********

Group: Members
Posts: 660
Joined: 31-August 06
From: Singapore
Member No.: 29,189



Thank you for the response, really quick!

I am at work now so unfortunately, I am not able to provide you with code listing of my style.css

I know it is a problem with the CSS because when I don't align the container to the center, everything works fine, the page does not shift at all.

I can't possibly give you a demo link as this wordpress test blog is hosted on my localhost, I am not sure how to install 2 instances of WordPress in my host. What I can do is to give you some screenshots though.

I am not mixing fluid with fixed layout, it is a pure 770px layout. The only problem is that the main page is positioned at say 0px (where 0px is the original position where it is supposed to be) and the rest of the pages like my post permalink and pages are positioned at say 5px. There is no change in the width of the container, just the position of it.

I will have a go at the
CODE
margin: 0 auto;


instead of
CODE
margin: 0 auto 0 auto;


Though, I am not sure what is the difference it would make. I will be going the entire look through my style sheet when I get back.

This post has been edited by darran: Jun 27 2007, 05:06 AM
Go to the top of the page
 
+Quote Post
jlhaslip
post Jun 27 2007, 05:36 AM
Post #7


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



CODE
margin: 0 auto 0 auto;

This sets the margins according to the pattern top, right, bottom, left.

CODE
margin: 0 auto;

This sets the margins according to the pattern top and bottom, left and right.

Effectively making each of these rules identical, so this is not the rule which is affecting the centring of your page.

IE uses text-align: center instead of the margin rule, so these two rules are typically combined in the CSS file to allow IE to center using one rule and the more compliant Browsers to use the margin rule.

As per previous posts, we would need to see the entire html code for the page as well as the CSS file.

What padding have you applied? And what Browser are you using?
Go to the top of the page
 
+Quote Post
darran
post Jun 27 2007, 01:31 PM
Post #8


Privileged Member
*********

Group: Members
Posts: 660
Joined: 31-August 06
From: Singapore
Member No.: 29,189



I have found what is wrong with the problem.

It was the container height, if I left it as it is, the page will shift position.

How do I get around this problem, if I set the container as 50 000 pixels, they don't seem to move but that doesn't seem like the way to go about this problem isn't it? Can anyone help?
Go to the top of the page
 
+Quote Post
jlhaslip
post Jun 27 2007, 01:57 PM
Post #9


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



how is it defined now?