CSS horizontal, vertical, center alignment

Use CSS properties to achieve various alignments, such as left alignment, center alignment, right alignment, vertical center alignment, etc.

##Method 1:Use float attributes to set left and right alignment

    实例 php.cn  
此DIV靠左对齐显示

Method 2:Use margin attribute for center alignment

Only required Add

margin:0 autoto the style to be centered.

    实例 php.cn  
此DIV居中对齐显示

Method 3:Use the position attribute to set left and right alignment

    实例 php.cn  
此DIV右对齐显示

Use Multi-attribute vertical center alignment:

    实例 php.cn   

完全居中:

利用css定位规则,设置左右、上下方向定位为0,margin为auto


Continuing Learning
||
实例 php.cn

完全居中:

利用css定位规则,设置左右、上下方向定位为0,margin为auto

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!