發(fā)現(xiàn)瀏覽器中字體可以比 12px 小, 是為什么?

<meta name="source" content="aomao">

1. 現(xiàn)象是這樣的:

8px 或者更小的 vw\vh\rem 單位的字體大小都能實(shí)現(xiàn),感覺違背 以前一直遵循的

“chrome有限制最小字體,為12px” 的事實(shí)
<meta name="source" content="aomao">


2. 說(shuō)明原因

參考:(如何打破Chrome的最小字號(hào)限制)[https://www.pipipi.net/39672.html]

簡(jiǎn)單來(lái)說(shuō)(直接上原因):

把最小字體設(shè)置成了0,就可以實(shí)現(xiàn) 0-12px的字體大小。

3. 正常實(shí)現(xiàn)小于最小字體大小12px

  • css 的 transform 的 scale 縮放配置
  • css 的 zoom 縮放進(jìn)行配置

測(cè)試代碼如下:

<template>
  <div class="test">
    <p style="font-size: 30px">猜猜我多大?</p>
    <p style="font-size: 0.2rem">猜猜我多大?</p>
    <p style="font-size: 0.02vw">猜猜我多大?</p>
    <p class="box">猜猜我多大?</p>
    111<br />
    <p class="box box1">猜猜我多大?</p>
    111<br />
    <p class="box box2">猜猜我多大?</p>
    111<br />
  </div>
</template>

<script>
export default {
  name: 'test',
}
</script>

<style>
.box {
  display: inline-block;
  width: 200px;
  height: 200px;
  line-height: 200px;
  text-align: center;
  font-size: 30px;
  background-color: antiquewhite;
  border: 1px solid blue;
}
.box1 {
  transform: scale(0.2);
}
.box2 {
  zoom: 0.2;
}
</style>

效果如下圖:(最小字體設(shè)為 20時(shí))

其中 zoom 和 transform 還是有區(qū)別的。

https://blog.csdn.net/ligang2585116/article/details/78745675

  1. 縮放的相對(duì)位置:zoom 相對(duì)左上角;scale 相對(duì)中心位置(通過(guò) transform-origin 修改基準(zhǔn)點(diǎn))。
  2. 縮放之后布局大小:zoom改變了元素占據(jù)的大小; scale 是元素實(shí)際占據(jù)不變,內(nèi)容縮放在中間。
  3. 兼容性。firefox下不支持zoom;scale針對(duì)IE9+。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容