[英]How do you change css when window size gets to a certain point in javascript
I want the font to adjust when the sc reen size gets to 1050px.我希望当屏幕大小达到 1050 像素时调整字体。 How do i do this with javascript
我如何使用 javascript 执行此操作
Add this to your css
:将此添加到您的
css
:
@media screen and (min-width: 1050px) {
body {
/* set font adjusters here */
}
}
you can do it with css and javascript你可以用 css 和 javascript 来完成
CSS CSS
@media screen and (min-width: 1050px) {
body {
font-size: // the value you want
}
}
JavaScript JavaScript
if(screen.width < your point) {
// change font size
}
you need to add event listener你需要添加事件监听器
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.