码迷,mamicode.com
首页 > 其他好文 > 详细

小div在大div中垂直居中方式

时间:2019-10-28 19:06:23      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:top   style   type   ott   absolute   doctype   lang   ima   img   

  代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>div居中</title>
  <style>
       * {
            margin:0;
            padding:0;
          }
          .content {
            width:400px;
            height:400px;
            background:orange;
            border: 1px solid green;
            position:relative;
            margin: 100px auto;
          }
          .nav {
            width:80px;
            height:80px;
            line-height:80px;
            text-align:center;
            background:green;
            margin: auto;
            position:absolute;
            left: 0;
            top: 0;
            bottom:0;
            right: 0;
          }
  </style>
</head>
<body>
  <div class="content">
         <div class="nav">这是内容</div>
    </div>
</body>
</html>

  效果:

技术图片

 

小div在大div中垂直居中方式

标签:top   style   type   ott   absolute   doctype   lang   ima   img   

原文地址:https://www.cnblogs.com/songtianfa/p/11752422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!