May 16, 2008

Css Alignment Bug - Moves my page when I click on a link

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)
Pages: 1, 2

free web hosting

Css Alignment Bug - Moves my page when I click on a link

darran
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.

Reply

BuffaloHELP
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.

Reply

Saint_Michael
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.

Reply

truefusion
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.

Reply

Saint_Michael
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.

Reply

darran
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.

 

 

 


Reply

jlhaslip
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?

Reply

darran
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?

Reply

jlhaslip
how is it defined now?

Reply

Saint_Michael
Was the container height smaller or bigger then the wrapper? Although I wouldn't think the smaller container would be such a problem.

I believe a z-index will need to be set up in order for your links to be on top of the container, or a z-index on that actual container so it stay above the rest of the template.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2

Searching Video's for css, alignment, bug, moves, page, click, link
advertisement



Css Alignment Bug - Moves my page when I click on a link



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE