如何让div居中

2026-04-06 19:57:54

1、css代码中给<body>标签添加{text-align:center;}元素,即文本居中对齐

如何让div居中

2、css代码给div居中标签命名为“.box”。添加{margin:0 auto;width:250px;height:180px;background-color:#f38989;}元素;

margin间距设为0左右自动、widht宽250、height高180、background-color背景粉红。

如何让div居中

3、在html代码<body>中添加<div>标签并引用css的类“box”居中

如何让div居中

4、最终梳理一下完整代码片段,打开浏览器演示效果。

如何让div居中

如何让div居中

相关推荐
  • 阅读量:100
  • 阅读量:159
  • 阅读量:33
  • 阅读量:75
  • 阅读量:153
  • 猜你喜欢