CSS3 Position Fixed centering problem

Source: Internet
Author: User

Typically, we want to center an element and do this:

#element {margin:0 Auto;}

Suppose you want to keep this element position fixed? In general we will join Position:fixed, for example the following:

#element {position:fixed;margin:0 Auto;}

But the result of this is. The element is not centered. This indicates that the fixedthe object is out of normal document flow.

How to resolve:

#element {position:fixed;margin:0 auto;left:0;right:0;}

However, you will not be able to work in the IE7 version number below to change it to:

#element {position:fixed;margin:0 Auto;left:auto;right:auto;}

Finally we can do this:

if ($.browser.msie && parseint ($.browser.version) <= 7) {    stralertwrapper.css ({position: ' fixed ', Bottom: ' 0 ', Height: ' Auto ', left: ' Auto ', right: ' Auto '}; }
Demo Sample code: http://jsfiddle.net/4Ly4B/33/
If you are helpful, welcome to add: QQ Group:124116463. Discuss the front-end technology together!






CSS3 Position Fixed centering problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.