一、使用margin属性进行水平对齐

*{margin:0px;}.div{width:70%;height:1000px;background-color:red;margin-left:auto;margin-right:auto;}

margin:值1 值2

值1代表上下 值2代表左右

*{margin:0px;}.div{width:70%;height:1000px;background-color:red;margin:100pxauto;}


二、使用position属性进行左右对齐

*{margin:0px;}.div{width:70%;height:1000px;background-color:red;position:absolute;right:0px;}


三、使用float属性进行左右对齐

*{margin:0px;}.div{width:70%;height:1000px;background-color:red;float:left;}