【问题标题】:Android WebView - Modal keeps scrolling to topAndroid WebView - 模态不断滚动到顶部
【发布时间】:2017-01-07 04:05:24
【问题描述】:

这里试过了,还是不行。

Prevent BODY from scrolling when a modal is opened

模态在这里:

<style>
    /* The Modal (background) */
    .modal {
        display: none; /* Hidden by default */
        position: fixed; /* Stay in place */
        z-index: 9999; /* Sit on top */
        left: 0px;
        top: 0px;
        width: 100%; /* Full width */
        height: 100%; /* Full height */
        overflow: auto; /* Enable scroll if needed */
        background-color: rgb(0,0,0); /* Fallback color */
        background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
    }

    /* Do not remove - Prevents android from jumping to top */
    body.modal-open {
        overflow: visible;
        position: fixed;
        width: 100%;
        height:100%;
    }

    /* Modal Content/Box */
    .modal-content {
        background-color: #fefefe;
        margin: 30% auto; /* 30% from the top and centered */
        padding: 0px;
        overflow-y:auto;
        border-radius: 10px;
        border: 0px;
        max-height:70%;
        width: 80%; /* Could be more or less, depending on screen size */
    }

    /* Modal Content/Box */
    .modal-image-content {
        z-index: 99999; /* Sit on top */
        padding: 0px;
        margin: auto; /*centered */
        border: 0px;
        max-height:100%;
        max-width:100%;
    }

    /* Links inside the dropdown */
    .modal-content a {
        color: black;
        padding: 10px;
        text-decoration: none;
        display: block;
    }

    /* Links inside the dropdown */
    .modal-content a:hover{
        background-color: #dddddd;
    }

    /* The Close Button */
    .close {
        color: #aaa;
        float: right;
        font-size: 28px;
        font-weight: bold;
    }

    .close:hover,
    .close:focus {
        color: black;
        text-decoration: none;
        cursor: pointer;
    }
</style>

如您所见,body.modal-open 是从解决方案中提取的,但它不起作用。

再次,如何使模态停止使屏幕滚动到顶部?

【问题讨论】:

    标签: android css webview


    【解决方案1】:

    这东西太奇怪了,我的 Google-fu 技能解决了它。

    改变 &lt;a href="#" ...

    &lt;a href="javascript: void(0);" ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多