比如某聘网首页,网页整体居中显示,中间横屏轮播图宽2000多像素,但是浏览器却不会显示滑动条,我做了一下只要有个div宽度超出浏览器显示范围就会自动出现左右滑块,要怎么做才能使其不会出现左右滑块?
3条回答 默认 最新
关注 海报宽设置成百分百,内容页面宽设置一个固定值,就是默认显示的值,max-width设置成100%,也就是你怎么放大最多也只能到百分百
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> #box1 { background-color: aqua; width: 800px; max-width: 100%; height: 200%; margin: 0 auto; } #box2 { background-color: red; width: 100%; height: 50vh; } </style> <body> <div id="box2"> <div id="box1"> </div> </div> </body> <script> </script> </html>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报