[英]How do you change css when window size gets to a certain point in javascript
我希望當屏幕大小達到 1050 像素時調整字體。 我如何使用 javascript 執行此操作
將此添加到您的css
:
@media screen and (min-width: 1050px) {
body {
/* set font adjusters here */
}
}
你可以用 css 和 javascript 來完成
CSS
@media screen and (min-width: 1050px) {
body {
font-size: // the value you want
}
}
JavaScript
if(screen.width < your point) {
// change font size
}
你需要添加事件監聽器
const handleResize = () => {
if(window.innerHeight > 1050) {
//you can change font size here
document.getElementById("yourelement").style.fontSize = "69px";
}
}
window.addEventListener('resize', handleResize)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.