Two Methods to Center a Layer with CSS - Web Programming - Chongqing Webmaster Network

by bluefirejj on 2008-07-19 20:00:47

1. By using the negative margin method and absolute positioning, the container can be absolutely centered relative to the screen. In this case, the nested container can only have an absolute size. (Standard) Control the proportion of negative margins and top/left to achieve absolute centering on the screen. If the container size changes, the margin, top, and left need to be readjusted.