无法将jQuery对话框设置为width< 150像素

时间:2015-01-23 20:29:53

标签: jquery dialog width jquery-ui-dialog

我似乎无法将jQuery对话框的宽度设置为小于150px。换句话说,如果我将它设置为更小的值,它仍然会以150px显示它。

对话框呼叫:

$('#menu')。dialog({modal:false,height:window.innerHeight-20,width:125,dialogClass:" no-close",position: {my:" right bottom",at:" right bottom&#34 ;, of:window}});

完整代码:



<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
        <script language="javascript">
            var menuOpen=false;
            function toggleFunctionMenu()
            {
                if(!menuOpen)
                {
                    $('#menu').dialog({modal:false, height:window.innerHeight-30, width:125,dialogClass: "no-close", position: { my: "right bottom", at: "right bottom", of: window }});
                    $('#menuButton').html("Close");
                    menuOpen=true;
                }
                else
                {
                    $('#menu').dialog("close");
                    $('#menuButton').html("Open");
                    menuOpen=false;
                }
            }


        </script>
        <style type="text/css">
            #menu
            {
                display: none;
                background-color: yellow;
                width:100%;
                height:100%;
                border-style:solid;
                border-width: 1px;
                border-color:black;
                
            }

              #menuButton
              {
                  float:right;
              }
        </style>
    </head>
    <body>
        <button onclick="toggleFunctionMenu()" id="menuButton">Open</button>
        <div id="menu">
        </div>
    </body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

<!DOCTYPE html>
<html>
    <head>
     <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <style type="text/css">
            #menu
            {
                display: none;
                background-color: yellow;
                width:100%;
                height:100%;
                border-style:solid;
                border-width: 1px;
                border-color:black;

            }

              #menuButton
              {
                  float:right;
              }
        </style>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
        <script language="javascript">
            var menuOpen=false;
            function toggleFunctionMenu()
            {
                if(!menuOpen)
                {
                    $('#menu').dialog({modal:false, height:window.innerHeight-30, width:'25px',dialogClass: "no-close", position: { my: "right bottom", at: "right bottom", of: window }});
                    $('#menuButton').html("Close");
                    menuOpen=true;
                }
                else
                {
                    $('#menu').dialog("close");
                    $('#menuButton').html("Open");
                    menuOpen=false;
                }
            }


        </script>
        </head>
           <body>
        <button onclick="toggleFunctionMenu()" id="menuButton">Open</button>
        <div id="menu">
        </div>
    </body>
    </html>