解决方式
1.简单直接
把属性值给html标签
html {
width: 100vw;
height: 100vh;
background: linear-gradient(45deg, rgb(139, 127, 127), rgb(34, 120, 191)) no-repeat;
}
2.给body加overflow:hidden(溢出隐藏)
html {
width: 100vw;
height: 100vh;
background: linear-gradient(45deg, rgb(139, 127, 127), rgb(34, 120, 191)) no-repeat;
}
3.设置为100%
body {
width: 100%;
height: 100%;
overflow: hidden;
background: linear-gradient(45deg, rgb(139, 127, 127), rgb(34, 120, 191)) no-repeat;
}
注:高度初始为0,看不出效果
4.计算滚动条宽度
侧栏滚动条:34px(web一般)
注:vh:计算就会变成100%
body {
width: (100vw-34px);
height: (100vh);
background: linear-gradient(45deg, rgb(139, 127, 127), rgb(34, 120, 191)) no-repeat;
}
原因自理😜