简体   繁体   English

从jQueryUI对话框中删除标题栏?

[英]Removing the title bar from jQueryUI Dialog?

How can I remove the title bar. 如何删除标题栏。

I checked the API here but could not find anything. 我在这里检查了API但找不到任何东西。

http://api.jqueryui.com/dialog/ http://api.jqueryui.com/dialog/

I noticed that other "solutions" have a cooler looking GUI then jQuery, particularly 我注意到其他“解决方案”具有更酷的GUI,然后是jQuery,尤其如此

http://www.ericmmartin.com/projects/simplemodal/ http://www.ericmmartin.com/projects/simplemodal/

However I'd like to use jQueryUI bc of all the resources...online API documentation, tutorials, etc. 但是我想使用所有资源的jQueryUI bc ...在线API文档,教程等。

I just need to know how to get rid of the title bar? 我只需要知道如何摆脱标题栏?

Thanks 谢谢

There are a few options. 有几个选择。

Hide with CSS 隐藏CSS
.ui-dialog-titlebar { display: none }

Hide with Javascript 使用Javascript隐藏
This will remove the title bar when the dialog is created, but it will preserve the close button. 这将在创建对话框时删除标题栏,但它将保留关闭按钮。

$("div").dialog({
  create: function( event, ui ) {
      var dialog = $(this).closest(".ui-dialog");
      dialog.find(".ui-dialog-titlebar-close")
            .appendTo(dialog)
            .css({
              position: "absolute",
              top: 0,
              right: 0,
              margin: "3px"
            });
      dialog.find(".ui-dialog-titlebar").remove();
  }
})​

See demo: http://jsfiddle.net/4AuhC/52/ 见演示: http //jsfiddle.net/4AuhC/52/

Given el as the original element from which the dialog was created: el作为创建对话框的原始元素:

$(el).siblings('.ui-dialog-titlebar').remove();

See http://jsfiddle.net/alnitak/N9TGd/ http://jsfiddle.net/alnitak/N9TGd/

Note that actually removing the titlebar (per the question title) will also remove the close button, and break the ability to drag the dialog box! 请注意,实际删除标题栏(根据问题标题)也将删除关闭按钮,并打破拖动对话框的能力!

Add this CSS after jQuery UI's CSS. 在jQuery UI的CSS之后添加这个CSS。

Be careful: no more close buttons and you can't drag it anymore! 小心:没有更多的关闭按钮,你不能再拖动它了!

.ui-dialog-titlebar { display: none }

jsFiddle: http://jsfiddle.net/PeVvA/ jsFiddle: http//jsfiddle.net/PeVvA/

If you want to keep drag and buttons, but it might not work on all themes.. 如果你想保持拖动和按钮,但它可能不适用于所有主题..

.ui-dialog-titlebar { background: none; border: 0px solid black }​

jsFiddle: http://jsfiddle.net/PeVvA/1/ jsFiddle: http//jsfiddle.net/PeVvA/1/

You could probably do more just by using CSS. 你可以通过使用CSS做更多的事情。 I'd probably play with height. 我可能会玩高度。

You can try adding this to your CSS directly.. 您可以尝试直接将其添加到CSS中。

.ui-dialog-titlebar
{ 
   display: none !important;
}

Try this: 尝试这个:

$(".ui-dialog-titlebar").hide()

(Or) (要么)

$("#dlg").dialog({
  open: function() {
    $(this).dialog("widget").find(".ui-dialog-titlebar").hide();
  }
});

If you want to remove the titelbar and keep the close icon using styles only, use the styles below. 如果要删除标题栏并仅使用样式保留关闭图标,请使用以下样式。 It shrinks the title bar to the size of the close icon and hides it behind. 它将标题栏缩小到关闭图标的大小并将其隐藏在后面。 ui-icons_6e6e6e_256x240.png I created by lightening the ui-icons_222222_256x240.png image that jqueryui comes with. ui-icons_6e6e6e_256x240.png我通过减轻ui-icons_222222_256x240.png附带的ui-icons_222222_256x240.png图像创建。

.ui-dialog .ui-dialog-titlebar.ui-widget-header{background: none; border: none; height: 20px; width: 20px; padding: 0px; position: static; float: right; margin: 0px 2px 0px 0px;}

.ui-dialog-titlebar.ui-widget-header .ui-dialog-title{display: none;}

.ui-dialog-titlebar.ui-widget-header .ui-button{background: none; border: 1px solid #CCCCCC;}

.ui-dialog .ui-dialog-titlebar .ui-dialog-titlebar-close{margin: 0px; position: static;}

.ui-dialog .dialog.ui-dialog-content{padding: 0px 10px 10px 10px;}

.ui-dialog .ui-dialog-titlebar .ui-dialog-titlebar-close .ui-icon{position: relative; margin-top: 0px; margin-left: 0px; top: 0px; left: 0px;}

.ui-dialog .ui-dialog-titlebar .ui-state-default .ui-icon {background-image: url("/css/ui-lightness/images/ui-icons_6e6e6e_256x240.png");}

.ui-dialog .ui-dialog-titlebar .ui-state-hover .ui-icon {background-image: url("/css/ui-lightness/images/ui-icons_222222_256x240.png");}

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

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