简体   繁体   中英

How can I scale font size of text to fit inside a div that also scales when the browser window is resized?

Hello I am fairly new to all of this. I have built my layout using divs that have their dimensions set as percentages so that they scale to the correct size when the browser window is resized. Some of the divs form buttons in a navigation bar (with text on each). But when I resize the browser window the text stays large. Is there any way to solve this?

Use this:

iStandardWidth = 960;
topofthetopdiv.style.zoom = parseInt(window.innerWidth/iStandardWidth, 10);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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