作者:zhanhailiang 日期:2015-01-28
css3新增了一个相对单位rem,其官方定义如下:
font size of the root element
rem单位和em单位都是相对大小,px是绝对大小。其区别在
目前,除了IE8及更早版本外,所有浏览器均已支持rem。对于不支持它的浏览器,应对方法也很简单,就是多写一个绝对单位的声明。这些浏览器会忽略用rem设定的字体大小。
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> /*浏览器默认font-size:16px;*/ /*%单位对于font-size、line-height等,是基于其父元素的font-size;*/ /*16px * 312.5% = 50px;*/ html{font-size: 312.5%;} /*50px * 0.5 = 25px; IE8及之前版本使用*/ body{font-size: 0.5rem; font-size\0:25px;} /*50px * 0.25 = 12px; IE8及之前版本使用*/ p{font-size: 0.25rem; font-size\0:12px;} </style></head><body>浏览器默认font-size:16px;<p> 浏览器默认font-size:16px;</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p></body>
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号