CSS中如何将列表居中?
以上图片中第二行<li>列表,我想居中显示,我这菜鸟调了很久也不行,请高手帮一下忙,谢谢!HTML:<divclass="main-1-right-t"><h1><ahr...
以上图片中第二行<li>列表,我想居中显示,我这菜鸟调了很久也不行,请高手帮一下忙,谢谢!
HTML:
<div class="main-1-right-t"> <h1><a href="/Item/13955.aspx" title="毛腾飞调研新区:抓住机遇 提升创新能力">毛腾飞调研新区:抓住机遇 提升创新能力</a></h1> <ul><li><a href="/Item/14003.aspx" target="_self">[我走读,我自豪]</a></li><li><a href="/Item/14000.aspx" target="_self">[走读感知新区]</a></li><li><a href="/Item/14002.aspx" target="_self">[如火如荼的建设场景]</a></li><li><a href="/Item/14001.aspx" target="_self">[高科集团四大在建项目复工]</a></li><li class="morett"><a href="/Category_237/index.aspx">[更多头条]</a></li> </ul> </div>
CSS代码:
.main-1-right .main-1-right-t { height: 72px; width: 773px; overflow: hidden; position: relative; border-bottom: 1px solid #ddd; text-align: center;}.main-1-right-t h1 a { font-family: "黑体"; font-size: 40px; text-decoration: none; display: inline-block; height: 45px; overflow: hidden; width: 773px; outline: none}.main-1-right-t p { height: 25px; line-height: 25px; position: absolute; right: 20px; bottom: -3px}.main-1-right-t .morett a { font-family: "宋体"; color: #f00; font-size: 14px; text-decoration: none; outline: none}.main-1-right-t ul { width: 770px; overflow: hidden; height: 23px; overflow: hidden; margin-top: 4px; text-align: center;}.main-1-right-t ul li { float: left; line-height: 23px; margin: 0px 5px; margin-left: 5px; text-align: center; height: 23px; overflow: hidden;} 展开
HTML:
<div class="main-1-right-t"> <h1><a href="/Item/13955.aspx" title="毛腾飞调研新区:抓住机遇 提升创新能力">毛腾飞调研新区:抓住机遇 提升创新能力</a></h1> <ul><li><a href="/Item/14003.aspx" target="_self">[我走读,我自豪]</a></li><li><a href="/Item/14000.aspx" target="_self">[走读感知新区]</a></li><li><a href="/Item/14002.aspx" target="_self">[如火如荼的建设场景]</a></li><li><a href="/Item/14001.aspx" target="_self">[高科集团四大在建项目复工]</a></li><li class="morett"><a href="/Category_237/index.aspx">[更多头条]</a></li> </ul> </div>
CSS代码:
.main-1-right .main-1-right-t { height: 72px; width: 773px; overflow: hidden; position: relative; border-bottom: 1px solid #ddd; text-align: center;}.main-1-right-t h1 a { font-family: "黑体"; font-size: 40px; text-decoration: none; display: inline-block; height: 45px; overflow: hidden; width: 773px; outline: none}.main-1-right-t p { height: 25px; line-height: 25px; position: absolute; right: 20px; bottom: -3px}.main-1-right-t .morett a { font-family: "宋体"; color: #f00; font-size: 14px; text-decoration: none; outline: none}.main-1-right-t ul { width: 770px; overflow: hidden; height: 23px; overflow: hidden; margin-top: 4px; text-align: center;}.main-1-right-t ul li { float: left; line-height: 23px; margin: 0px 5px; margin-left: 5px; text-align: center; height: 23px; overflow: hidden;} 展开
展开全部
.main-1-right-t ul {
margin: 0 auto;
}
margin: 0 auto;
}
追问
加了这段代码或只保留其中这段代码都不起作用,麻烦你再看看有其他办法吗?谢谢!
追答
.main-1-right-t ul li {
display: inline-block;
*display: inline;
*zoom: 1;
line-height: 23px;
margin: 0px 5px;
margin-left: 5px;
text-align: center;
height: 23px;
overflow: hidden;
}
.main-1-right-t ul的宽度不用设置
ul和li要去掉默认样式
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询