简体   繁体   English

如何在jQuery对话框内的两个按钮之间使文本垂直居中对齐?

[英]How to center align vertically a text in between two buttons inside a jQuery dialog box?

I want to center or bottom align vertically a text in between two buttons inside a jQuery Dialog box. 我想在jQuery对话框内的两个按钮之间垂直居中或底部对齐文本。 I have tried several methods but none of them seem to work. 我尝试了几种方法,但似乎都没有用。 What am I doing wrong here? 我在这里做错了什么?

My code is as follows: 我的代码如下:

<!doctype html>
<html lang="en">
<head>
   <meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>



<script type="text/javascript">

    $(function () {
        $("#dialog_nav").dialog({
            autoOpen: false,
            modal: true,
            dialogClass: "First_Dialog",
            resizable: false,
            buttons: [
                {

                    text:"Login",
                    class:"Login_Class",
                    click: function () {
                       //
                    }
                },
                {
                    text:"SignUp",
                    class:"Sign_Up_Class",
                    click: function () {
                        //
                    }
                }
            ]


        });



        $("#Dialog_Modal").on("click", function (event) {
            $("#dialog_nav").dialog("open");
        });

        //$(".ui-dialog-buttonpane button:first").after('<span>Or</span>');

        $(".ui-dialog-buttonset > button:first-child").css("float", "left");
        $(".ui-dialog-buttonset > button:last-child").css("float", "right");

        $(".Login_Class").after('<span class="Span_Text">Or</span>');

});



</script>


<style type="text/css">
    .First_Dialog .ui-dialog-titlebar-close{
        display:none;
    }
    .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset
    {
        float:none; 
    }
    .ui-dialog .ui-dialog-buttonpane
    {
        text-align:center;
    }
    span.Span_Text
    {
        text-align:center;
        vertical-align:bottom;
    }




</style>

</head>
<body>

<div id="dialog_nav" title="Basic Modal dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div> 
<input type="button" id="Dialog_Modal" value="Click to open a modeless dialog" /> 
</body>
</html>

Give this code in CSS: 在CSS中提供以下代码:

span.Span_Text {line-height: 3.5em;}

Fiddle: http://jsbin.com/biheqemi/1/edit 小提琴: http : //jsbin.com/biheqemi/1/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM