固定定位的标题在桌面上持续存在,但在移动设备上不存在?

ale*_*nco 3 html css mobile

如果缩小浏览器,您将看到一个.header-mobile元素。它是固定定位的。它在桌面上仍然存在,但在移动设备上它只留在顶部。

这是移动 CSS:

@media handheld, only screen and (max-width: 767px) {

  #header,
  #header-fixed {
    display: none;
  }

  #header-mobile {
    background: url(images/header-fixed-bg.png) repeat-x 0 0;
    border-bottom: 1px solid #111;
    display: block;
    position: fixed;
    top: 0;
    width: 100%;
    -webkit-box-shadow: rgba(0,0,0,0.3) 0 0 4px;
    -moz-box-shadow: rgba(0,0,0,0.3) 0 0 4px;
    box-shadow: rgba(0,0,0,0.3) 0 0 4px;
  }
Run Code Online (Sandbox Code Playgroud)

HTML:

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </header>
  <div id="header-mobile">
    <div id="header-mobile-content">
      <h1 class="logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">test</a></h1>
      <a class="button button-small" href="">
        <img src="<?php bloginfo( 'template_url' ); ?>/images/icon-button.png" alt="" />
        <span>Request a quote</span>
      </a>
      <ul class="navigation-mobile">
        <li>
          <a class="responsive" href="#responsive">
            <span>Responsive Design</span>
          </a>
        </li>
        <li>
          <a class="touch" href="#touch">
            <span>Touch Friendly</span>
          </a>
        </li>
        <li>
          <a class="programming" href="#programming">
            <span>Custom Programming</span>
          </a>
        </li>
        <li>
          <a class="mobile" href="#mobile">
            <span>Mobile/Site Apps</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

直播网站:http : //www.hfwebdesign.com/?ModPagespeed=off

可能是什么原因?

ale*_*nco 6

我不知道为什么,但我不得不添加这个:

  <meta content='width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no' name='viewport'>
Run Code Online (Sandbox Code Playgroud)

  • OMG,非常感谢你,我已经为此苦苦挣扎了很长时间。添加“user-scalable=no”就可以了。 (2认同)