简体   繁体   English

为什么我的元素使用 2 种不同的字体大小?

[英]Why my element uses 2 different font-sizes?

I set a font-size as global.我将字体大小设置为全局。 That changes when browser's width change(kind of fluid typography).当浏览器的宽度改变(一种流畅的排版)时,情况就会改变。 I setted that to body element.我将其设置为 body 元素。

But when size of browser changes, then it changes(font-size).但是当浏览器的大小改变时,它就会改变(字体大小)。 Why?为什么? and How can I stop this?我该如何阻止呢?

 *, html { -webkit-box-sizing: border-box; box-sizing: border-box; } body { margin: 0; padding: 0; font-size: calc(16px +.75vw); }.container { background-color: #d1c6c6; padding: 10px; min-height: 100vh; }.container__box { font-weight: bold; color: white; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; padding: 15px 10px; background-color: #8b2be4; width: 90vw; font-size: 30px; }
 <meta name="viewport" content="width=device-width, initial-scale=1.0"> <div class="container"> <div class="container__box">Gridfan Jessica</div> </div>

But when size of browser changes, then it changes(font-size).但是当浏览器的大小改变时,它就会改变(字体大小)。 Why?为什么?

Because you used vw font size changes when browser size changes.因为您在浏览器大小更改时使用了vw字体大小更改。

How can I stop this?我怎样才能阻止这个?

Use px instead.请改用px If that's not eye comfortable, Use media query for different font sizes for different screen widths.如果这让眼睛不舒服,请针对不同屏幕宽度使用不同字体大小的媒体查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM