简体   繁体   中英

Width of div changes when position becomes fixed from relative

The width of the div "topNav" changes by few pixels when its position style is changed from relative to fixed. I found a jquery plugin (http://imakewebthings.github.com/jquery-waypoints/) which can perform the same functionality I'm looking for elegantly, but I feel it is a overkill for this purpose.

EDIT: My question is how to avoid changing the div sizes.

Check out the code at :

http://jsbin.com/azace5/edit

You need to remove the page's "default margin". This will do it in "every browser":

html, body {
    margin: 0;
    padding: 0
}

See: http://jsbin.com/azace5/2

或者,您可以添加最小宽度。

min-width:600px;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM