0

我在我的 jQUeryMobile 应用程序上使用 jQuery Autocomplete。它工作完美。现在我试图显示垂直滚动条来滚动查找项目列表。滚动条显示在桌面浏览器上,但不在 Android 设备上。我的CSS看起来像这样:

.ui-autocomplete { 最大高度:100px; 溢出-y:自动;/* 防止水平滚动条 */ overflow-x: hidden; }

有人可以帮忙吗,谢谢!

4

2 回答 2

0

尝试将溢出属性设置为自动..

overflow: auto;
于 2013-02-18T07:17:42.690 回答
0
Resolved by using jscrollpane. see below code:

<!DOCTYPE html>
<html>
<head>
    <title>Page Title</title>
    <link rel="stylesheet" href="css/jquery-ui.css" />

    <script type="text/javascript" src="Scripts/jquery.min.js"></script>

    <script type="text/javascript" src="Scripts/jquery-ui.min.js"></script>

    <link rel="stylesheet" href="http://jscrollpane.kelvinluck.com/style/jquery.jscrollpane.css" />

    <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/jquery.jscrollpane.min.js"></script>

    <script type="text/javascript">
        $(function() {
            var availableTags = [{
                real_value: 1,
                label: "c++"
            },
                {
                    real_value: 1,
                    label: "ActionScript"
                },
                {
                    real_value: 2,
                    label: "AppleScript"
                },
                {
                    real_value: 3,
                    label: "Asp"
                },
                {
                    real_value: 4,
                    label: "BASIC"
                },
                {
                    real_value: 5,
                    label: "C"
                },
                {
                    real_value: 6,
                    label: "C++"
                },
                {
                    real_value: 7,
                    label: "Clojure"
                },
                {
                    real_value: 8,
                    label: "COBOL"
                },
                {
                    real_value: 9,
                    label: "ColdFusion"
                },
                {
                    real_value: 10,
                    label: "Erlang"
                },
                {
                    real_value: 11,
                    label: "Fortran"
                },
                {
                    real_value: 12,
                    label: "Groovy"
                },
                {
                    real_value: 13,
                    label: "Haskell"
                },
                {
                    real_value: 14,
                    label: "Java"
                },
                {
                    real_value: 15,
                    label: "JavaScript"
                },
                {
                    real_value: 16,
                    label: "Lisp"
                },
                {
                    real_value: 17,
                    label: "Perl"
                },
                {
                    real_value: 18,
                    label: "PHP"
                },
                {
                    real_value: 19,
                    label: "Python"
                },
                {
                    real_value: 20,
                    label: "Ruby"
                },
                {
                    real_value: 21,
                    label: "Scala"
                },
                {
                    real_value: 22,
                    label: "Scheme"
                }
            ];

            $("#tags").autocomplete({
                source: availableTags,
                open: function(event, ui) {
                    $('.ui-autocomplete')
                        .addClass('scroll-pane')
                        .jScrollPane();

                    $('.jScrollPaneContainer').css({
                        'position': 'absolute',
                        'top': ($(this).offset().top +
                   $(this).height() + 5) + 'px',
                        'left': $(this).offset().left + 'px'
                    });
                },
                close: function(event, ui) {
                    $('.scroll-pane').jScrollPaneRemove();
                },
                select: function(event, ui) {
                    alert(ui.item.label);
                    alert(ui.item.real_value);
                }
            });
        });
    </script>

    <style>
        .ui-autocomplete
        {
            max-height: 100px;
            overflow: auto;
        }
    </style>
</head>
<body>
    <div>
        <input type="text" id="tags" />
    </div>
</body>
</html>
于 2013-02-18T09:53:07.137 回答