zoukankan      html  css  js  c++  java
  • 黑科技!两行代码完美解决:同时设置overflow-x:hidden,overflow-y:visible无效的问题

    不废话,直接上代码

    <!DOCTYPE html>
    <html>
      <head>
        <style>
          body {
            padding: 0;
            margin: 0;
            height: 800px;
            display: flex;
            justify-content: center;
            align-items: center;
          }
          .parent {
            width: 80vw;
            height: 200px;
            background-color: aqua;
            display: flex;
            align-items: center;
          }
          .wrapper {
            width: 100%;
            display: flex;
            align-items: center;
            overflow-x: hidden;
            overflow-y: visible;
            padding: 500px 0; /*极为重要的两行代码 */
            margin: -500px 0; /* 具体值可以根据实际情况调整 */
          }
    
          .imgDiv {
            padding-left: 50px;
          }
    
          .child {
            width: 70px;
            height: 100px;
          }
    
          .child:hover {
            transform: scale(4, 4);
          }
        </style>
      </head>
      <body>
        <div class="parent">
          <div class="wrapper">
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
            <div class="imgDiv">
              <img
                class="child"
                src="https://img1.gamersky.com/upimg/pic/2019/05/27/201905271412133676.jpg"
              />
            </div>
          </div>
        </div>
      </body>
    </html>

    参考链接:

    https://stackoverflow.com/questions/6421966/css-overflow-x-visible-and-overflow-y-hidden-causing-scrollbar-issue/39554003#39554003

  • 相关阅读:
    刷新页面的问题
    JS属性
    1-4_基本概念_进程间通信及同步
    1-3_基本概念_程序&进程
    1-2_基本概念_用户和组&目录、链接及文件
    1-1_基本概念_内核&shell
    d 操作系统概述
    对比生成测试算法用例
    简单的排序算法:冒泡排序法
    简单的排序算法:插入排序法
  • 原文地址:https://www.cnblogs.com/ImaY/p/11101937.html
Copyright © 2011-2022 走看看