搜索

网页设计中怎样设置所有内容居中

发布网友 发布时间:2022-04-21 04:57

我来回答

4个回答

热心网友 时间:2022-04-21 04:57

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>居中div演示效果</title>
<style type="text/css">
.align-center{
margin:0 auto; /* 居中 这个是必须的,,其它的属性非必须 */
width:500px; /* 给个宽度 顶到浏览器的两边就看不出居中效果了 */
background:red; /* 背景色 */
text-align:center; /* 文字等内容居中 */
}
</style>
</head>

<body>
<div class="align-center">居中div演示效果<br/><br/>更多代码请访问 <a href="http://www.poluoluo.com/" target="_blank">破洛洛</a></div>
</body>
</html>

热心网友 时间:2022-04-21 06:15

你设置好一个外围divd的宽度,然后margin:0 auto;就可以了
demo:
<div style="margin:0 auto;width:960px;height:auto;">你所有的内容写这里</div>

热心网友 时间:2022-04-21 07:50

在CSS里面可以设置<body></body>属性设置居中就可以了.

热心网友 时间:2022-04-21 09:41

在需要居中内容的前后加上<center>内容内容内容</center>
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top