【问题标题】:Modal box on iPhone no scrolliPhone上的模态框没有滚动
【发布时间】:2012-08-17 13:29:58
【问题描述】:

你好想知道我是否可以得到一些帮助,因为我在网上没有找到任何可以解决这个问题的东西,在 iphone 上,当页面很大时,twitter 引导模式框没有滚动来获取框的页脚。

使用的代码

    <div class="modal hide" id="electricityModal">

        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3>Submit A Electricity Reading</h3>
        </div>

        <div class="modal-body">

            <div class="control-group">
                <label class="control-label">Date/Time</label>
                    <div class="controls">
                        <span class="input-medium uneditable-input">22 Aug 2012, 9:45AM</span>
                    </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="reading-peak">Peak</label>
                <div class="controls">
                    <input style="letter-spacing: 10px;" type="text" id="reading-peak" class="input-medium">
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="reading-off-peak">Off Peak</label>
                <div class="controls">
                    <input style="letter-spacing: 10px;" type="text" id="reading-off-peak" class="input-medium">
                </div>
            </div>

        </div>

        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-primary">Lodge Reading</button>
        </div>
    </div>

【问题讨论】:

    标签: iphone html twitter-bootstrap


    【解决方案1】:

    我相信为父 div (id:electricityModal) 提供 max-height css 属性可能会有所帮助并提供滚动条。选择最适合您的高度。说像 250 像素这样的东西。

    【讨论】:

    • 在进行更多搜索后尝试了该方法并没有解决问题。
    【解决方案2】:

    解决此问题的方法是添加以下 css(在 bootstraps github 问题上找到)

        @media (max-width: 480px) {
    
            .modal {
                height: 500px; /* Set a default max height of the modal (adjusted later)*/
                position: fixed; /* Display modal in the centre of your screen */
                overflow-y: scroll; /*  Ensure that the modal is scroll-able */
                -webkit-overflow-scrolling: touch; /* Avoid having to use 2 finger scroll on iOS    */
            }
            .modal.fade.in{
                top: 5px; /* Use more screen real estate */
            }
            .modal-body{
                /* Increase the max height of the modal body to try & avoid both it,
                 * and the modal container having scroll bars which results in odd behavior */ 
                max-height: 2400px; 
            }   
        }
    
        /* Now adjust the height so it handles various screen sizes & orientations */
        /* You could make this as granular as you like, or have it more granular at common screen sizes
         * but it should start at the height we set on .modal (i.e. 500px) & work down */
        @media (max-width: 480px) and (max-height: 500px){.modal{ height: 450px}}
        @media (max-width: 480px) and (max-height: 450px){.modal{ height: 400px}}
        @media (max-width: 480px) and (max-height: 400px){.modal{ height: 350px}}
        @media (max-width: 480px) and (max-height: 350px){.modal{ height: 300px}}
        @media (max-width: 480px) and (max-height: 300px){.modal{ height: 250px}}
        @media (max-width: 480px) and (max-height: 250px){.modal{ height: 200px}}
        @media (max-width: 480px) and (max-height: 200px){.modal{ height: 150px}}
    

    【讨论】:

    • 对我来说只是部分修复。表格现在是可滚动的,但仅限于第一次显示。一旦我滚动它一次或尝试操作其中的任何表单对象,整个事情就会再次中断。呵呵。谢谢你的分享!
    • 这并没有解决我的特殊问题,但帮助了我。谢谢!
    • 类似于@Kirill,这对我来说是几乎!它最初可以工作,但是当我尝试从下拉列表中选择一个值(iPhone 完全破坏)时,错误返回。我假设他们正在修改页面元素以恢复此 css 修复:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多