好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用position:fixed属性让DIV居中

先看一下效果 :
http://www.keleyi .COM /keleyi/pht ML /fixed center .htm
关键代码是 : # topmenu_keleyi_com{pos IT ion:fixed;left:0px;right:0px;width:706px ;m arg in-left:auto;mar gin -right:auto;}
附完整代码 :

复制代码

代码如下:


<!DOCTY PE html P ub LIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. org /TR/xhtml1/DTD/xhtml1 -t ransitional.dtd">
<html XM lns="http://www.w3.org/1999/xhtml">
<head>
<title>使position:fixed的DIV居中-柯乐义</title>
<style type="text/css">
#topmenu_keleyi_com{position:fixed;left:0px;right:0px;width:706px;margin-left:auto;margin-right:auto;top:100px;h ei ght:50px;background-color: red ;}
#topmenu_keleyi_com li{float:left;
list -s tyle:none;
margin-right:1px;
width:116px;
background-color:#e0f0e0;
}
#topmenu_keleyi_com ul{ margin:0px;padding:0px;}
body{margin:0px;}
</style>
</head>
<body>
<div id="topmenu_keleyi_com">
<ul><li><a hr ef="http://www.keleyi.com/menu/net/" target="_blank">.NET</a></li>
<li><a href="http://www.keleyi.com/menu/javascript/" target="_blank">Javascript</a></li>
<li><a href="http://www.keleyi.com/menu/ jq uery/" target="_blank">jQuery</a></li>
<li><a href="http://www.keleyi.com/menu/ csharp /" target="_blank">C#</a></li>
<li><a href="http://www.keleyi.com/menu/other/" target="_blank">其他</a></li>
<li><a href="http://www.keleyi.com/" target="_blank">首页</a></li></ul>
position:fixed的DIV的居中效果, 改变 页面的 宽 度看看。
</div>
</body>
</html>

总结

以上是 为你收集整理的 使用position:fixed属性让DIV居中 全部内容,希望文章能够帮你解决 使用position:fixed属性让DIV居中 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于使用position:fixed属性让DIV居中的详细内容...

  阅读:19次