代码之家  ›  专栏  ›  技术社区  ›  i.maddy

在移动视图中隐藏html按钮

  •  0
  • i.maddy  · 技术社区  · 8 年前

    JSFIDLE代码:

    https://jsfiddle.net/cgqme8xo/1/#&togetherjs=qTV1soRSqs

    <section>
    <a href="#main" class="scroll-down" address="true" class="text-right hidden-md"></a>
    </section>
    

    CSS:

    .scroll-down {
      opacity: 1;
      -webkit-transition: all .5s ease-in 3s;
      transition: all .5s ease-in 3s;
    }
    
    .scroll-down {
      position: absolute;
      bottom: 30px;
      left: 50%;
      margin-left: -16px;
      display: block;
      width: 32px;
      height: 32px;
      border: 2px solid #EF4043;
      background-size: 14px auto;
      border-radius: 50%;
      z-index: 2;
      -webkit-animation: bounce 2s infinite 2s;
      animation: bounce 2s infinite 2s;
      -webkit-transition: all .2s ease-in;
      transition: all .2s ease-in;
    }
    
    
    .scroll-down:before {
        position: absolute;
        top: calc(50% - 8px);
        left: calc(50% - 6px);
        transform: rotate(-45deg);
        display: block;
        width: 12px;
        height: 12px;
        content: "";
        border: 2px solid #EF4043;
        border-width: 0px 0 2px 2px;
    }
    
    5 回复  |  直到 8 年前
        1
  •  1
  •   Kurohige    8 年前

    在Bootstrap 3中,可以使用Bootstrap Responsive Utilities

    <section >
        <a href="#main" class="scroll-down text-right hidden-xs" address="true"></a>
    </section>
    

    在Bootstap 4中 Responsive Utilities

    <section >
        <a href="#main" class="scroll-down text-right hidden-xs-down" address="true"></a>
    </section>
    
        2
  •  0
  •   caramba    8 年前

    只需使用以下内容:

    @media (max-width: 600px) {
      .scroll-down {
        display: none;
      }
    }
    

    根据需要隐藏按钮的宽度

    此处更新了fiddle: https://jsfiddle.net/cgqme8xo/2/

        3
  •  0
  •   kyun    8 年前
    @media screen and (max-width: 460px) {
      .scroll-down{
        display: none;
      }
    }
    @media screen and (min-width: 461px) {
      .scroll-down{
        display: block;
      }
    }
    

    使用如何 @media screen

        4
  •  0
  •   blendenzo    8 年前

    由于您使用的是Bootstrap,因此您可以在没有自定义CSS的情况下这样做:

    <section class="d-none d-md-block">
      <a href="#main" class="scroll-down" address="true" class="text-right"></a>
    </section>
    

    改变 d-md-block 到最适合您需要的断点和显示类型。看见 the Bootstrap documentation 查看可用选项。

        5
  •  0
  •   James Douglas    6 年前

    @media 查询

    第一步是放置视口 <meta> 中的标记 <head> 您的HTML:

    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    

    然后使用 从CSS查询:

    @media only screen and (max-width: 768px) {
      .scroll-down {
        display: none;
      }
    }
    

    你可以改变 max-width: 768px

    尝试调整浏览器的大小,看看它是否工作。