Blogger Information
Blog 34
fans 0
comment 0
visits 26637
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
浅谈css中三种常用元素单位
罗盼的博客
Original
724 people have browsed it

实例

<div class="px"> px </div>
<div class="em"> em </div>
<div class="rem"> rem </div>

<style type="text/css">
.px {
    font-size: 20px;
    width: 100px;
    background: green;
    text-align: center;
    line-height: 100px;
}
.em {
    font-size: 20px;
    width: 5em;
    background: blue;
    text-align: center;
    line-height: 5em;
    
}

.rem {
    font-size: 1.25rem;
    width: 6.25rem;
    background: pink;
    text-align: center;
    line-height: 6.25rem;
    
    
}

</style>

运行实例 »

点击 "运行实例" 按钮查看在线实例

下面为手写代码:

微信图片_20180816170715.jpg

感悟:px是相对于屏幕显示器显示的css元素单位,em是相对于当前字体的大小显示的css元素单位,rem根元素单位,相对于根元素显示的css元素单位(想必H5与c3的自适应精髓在rem元素单位的引入,个人见解,欢迎吐槽)!



Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments