博主信息
博文 30
粉丝 0
评论 0
访问量 28162
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
1021.作业-rem.em,px,vh,vw示例
归宿的博客
原创
902人浏览过

‘’’
<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>作业</title>
<style>
:root{font-size: 0.625em;}
.box1{
width: 50rem;
height: 50rem;
font-size: 1.6rem;
border: 1px solid ;
}
.box1 > p:first-of-type{
font-size: 1.2em;
background-color:lightcoral;
line-height: 2em;
border-radius: .5em;

  1. }
  2. .box1 > p:nth-of-type(2){
  3. font-size: 1.5rem;
  4. line-height: 2rem;
  5. background-color: lawngreen;
  6. border-radius: .5rem;
  7. }
  8. .box1 > p:last-child{
  9. font-size: 16px;
  10. line-height: 20px;
  11. background-color: yellow;
  12. border-radius: 10px;
  13. }
  14. /* 作业2 */
  15. .menu{
  16. width: 40rem;
  17. height: 40rem;
  18. border: 1px solid lightcoral;
  19. }
  20. .menu > p{
  21. height: 10vh;
  22. width: 20vh;
  23. margin: 0;
  24. }
  25. .menu > p:first-child{
  26. background-color:green ;
  27. }
  28. .menu > p:nth-of-type(2){
  29. background-color:red ;
  30. }
  31. .menu > p:last-child{
  32. background-color:green ;
  33. }
  34. </style>

</head>

<body>
<h1>1.演示em,rem,px的应用场景,并指出em,rem的区别与联系</h1>
<div class="box1">
<p><strong>我是em,</strong> </br>我的字体大小是父级元素box里font-size的1.2倍,也就是19.2px</p>
<p><strong>我是rem,</strong> </br>我的字体大小是依据根元素(root)的1.5倍,也就是15px</p>
<p><strong>我是px</strong></br>我的字体大小是依据具体的属性值来决定的</p>
</div>
<p>
区别和使用场景: <br>
em:使用在padding,margin;border-radius;
rem:使用在fontsize,
px:一般使用边框宽度
</p>
<h2>2.使用vh,vw写一个三行单列的手机首页布局</h2>
<div class="menu">
<p></p>
<p></p>
<p></p>
</div>
</body>
</html>
‘’’

本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学