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

伪元素:before和:after的简单应用——清除浮动

时间:2018-11-19 20:28:46      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:lang   nav   after   min   doctype   1.0   content   otc   head   

HTML代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>demo</title>
  <link rel="stylesheet" href="https://cdn.bootcss.com/normalize/8.0.0/normalize.min.css">
  <link rel="stylesheet" href="css/main.css">
</head>
<body>
  <div class="nav">
      <div class="container clear-float" >
        <div class="fl">
          <span>首页</span>
        </div>
        <div class="fr">
          <span>item</span>
          <span>item</span>
          <span>item</span>
          <span>item</span>
          <span>item</span>
        </div>
      </div>
  </div>
</body>
</html>

CSS代码:

.container{
  display: block;
  max-width: 1080px;
  margin: 0 auto;
}

.fl{
  float: left;
}

.fr{
  float: right;
}

.clear-float:after,
.clear-float:before{
  content: " ";
  display: block;
  clear:both;
}

 

伪元素:before和:after的简单应用——清除浮动

标签:lang   nav   after   min   doctype   1.0   content   otc   head   

原文地址:https://www.cnblogs.com/wuaidongfang/p/9984485.html

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