前端web网页制作%和em的区别

简单来说%是浏览器百分比单位,em是电脑屏幕的百分比单位

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <title></title>
 <link rel="stylesheet" href="">
</head>
<style type="text/css" media="screen">
 *{
  padding: 0px;
  margin: 0px;
 }
 .bigbox{
  width: 100px;
  height: 100px;
  margin-left: 20%;
  background: red;
  float:left;
 }
 .smallbox{
        width: 100px;
        height: 100px;
        margin-left:20em;
        background:yellow;
       
 }
 body{
  background: #2FB0FF;
 }
</style>
<body >
 <div class="bigbox">
  
 </div>
 <div class="smallbox">
   
 </div>
</body>
</html>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/jiwei_1234____5/article/details/83548816
今日推荐