1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <style type="text/css">
5 #container{
6 background: #090;
7 width: 500px;
8 height: 96px;
9 position: relative;
10 left: 50%;
11 margin-left: -250px;
12 /*margin-left: expression(-(this.offsetWidth/2)+"px");*/
13 }
14 </style>
15 </HEAD>
16
17 <BODY>
18 <div id="container">
19 我们在做什么?
20 </div>
21 </BODY>
22 </HTML>
23
2 <HTML>
3 <HEAD>
4 <style type="text/css">
5 #container{
6 background: #090;
7 width: 500px;
8 height: 96px;
9 position: relative;
10 left: 50%;
11 margin-left: -250px;
12 /*margin-left: expression(-(this.offsetWidth/2)+"px");*/
13 }
14 </style>
15 </HEAD>
16
17 <BODY>
18 <div id="container">
19 我们在做什么?
20 </div>
21 </BODY>
22 </HTML>
23
对那个"expression"还不熟悉噢.
也可以使用:
1 body {TEXT-ALIGN: center;}
2 #center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }
2 #center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }