为了账号安全,请及时绑定邮箱和手机立即绑定

ul列表在div中三种居中方式怎么弄啊

问老师,ul列表在div中三种居中方式怎么弄啊,谢谢

正在回答

4 回答

学习收藏  谢谢

0 回复 有任何疑惑可以回复我~

额  我懂了 

0 回复 有任何疑惑可以回复我~
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>淘宝搜索框</title>
    <style type="text/css">
 .test1,.test2,.test3{
 height: 100px;
 background-color: #ccc;
 margin-top: 20px;
        }
 ul{
 list-style: none;
 overflow: hidden;
 padding: 0;
 margin: 0;
 width: 360px;
        }

 ul li{
 height: 20px;
 width: 100px;
 background-color: #00aaaa;
 float: left;
 margin-right: 20px;
 text-align: center;
        }
        .test1 ul{
 margin: 0 auto;
        }
        .test2{
 position: relative;
        }
        .test2 ul{
 position: absolute;
 left: 0;
 top: 50%;
 transform:translate(0,-50%);
 }

        .test3{
 position: relative;
        }
        .test3 ul{
 position: absolute;
 left: 50%;
 top: 50%;
 transform:translate(-50%,-50%);
 }
 </style>
</head>
<body>
<div class="test1">
    <ul>
        <li>水平居中</li>
        <li>水平居中</li>
        <li>水平居中</li>
    </ul>
</div>
<div class="test2">
    <ul>
        <li>垂直居中</li>
        <li>垂直居中</li>
        <li>垂直居中</li>
    </ul>
</div>
<div class="test3">
    <ul>
        <li>水平垂直居中</li>
        <li>水平垂直居中</li>
        <li>水平垂直居中</li>
    </ul>
</div>
</body>
</html>


1 回复 有任何疑惑可以回复我~
#1

sealkie 提问者

额 我懂了 谢谢
2015-11-09 回复 有任何疑惑可以回复我~

你说的三种居中方式指的是什么?

0 回复 有任何疑惑可以回复我~
#1

sealkie 提问者

水平居中 垂直居中 和水平垂直居中吧
2015-11-07 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
HTML5和CSS3扁平化风格博客
  • 参与学习       86786    人
  • 解答问题       406    个

HTML5与CSS3搭建超酷扁平化风格博客

进入课程

ul列表在div中三种居中方式怎么弄啊

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号