简体   繁体   English

从jQuery对话框中删除没有十字按钮的标题栏

[英]Remove title bar without the cross button from jQuery Dialog box

I have seen multiple answers for this question but have not been able to find any that work. 我看到了这个问题的多个答案,但是找不到任何可行的方法。

How do i remove the title bar from a jQueryUI Dialog box while keeping the close button. 如何在保持关闭按钮的同时从jQueryUI对话框中删除标题栏。

I have tried this and it does not work. 我已经尝试过了,但是行不通。 Also it is not a good solution. 也不是一个好的解决方案。

$("#example").dialog(dialogOpts);
// remove the title bar
$(".ui-dialog-titlebar").hide();

I was able to follow this and get rid of the title bar. 我能够按照此操作并摆脱标题栏。 But this also takes away the close button and because there is no title bar, the dialog box is not draggable anymore. 但这也带走了关闭按钮,并且由于没有标题栏,因此该对话框不再可拖动。

jquery UI dialog: how to initialize without a title bar? jQuery UI对话框:如何在没有标题栏的情况下初始化?

I tried to follow this fiddle here to get rid of the title bar and keep the close button. 我试图按照这里的小提琴来摆脱标题栏,并保持关闭按钮。

http://jsfiddle.net/NK2qm/2/ http://jsfiddle.net/NK2qm/2/

However, this modifies the CSS for all dialog boxes and adds a triangle below the dialog box. 但是,这会修改所有对话框的CSS,并在对话框下方添加一个三角形。 I want this to happen only for one class of dialog box and minus the triangle at the bottom. 我希望仅对一类对话框发生这种情况,并减去底部的三角形。

Can someone reply to this question with a fiddle showing how to do it? 有人可以用小提琴回答这个问题的方法吗?

Thanks. 谢谢。

One solution might be to create a second instance of the jQueryUI dialog and specifically target that instance in the CSS. 一种解决方案可能是创建jQueryUI对话框的第二个实例,并专门在CSS中定位该实例。

jsFiddle Demo jsFiddle演示

CSS will look like this: CSS将如下所示:

[aria-labelledby=ui-id-2].ui-dialog .ui-dialog-titlebar {
    background:transparent;
    border:none;
}
[aria-labelledby=ui-id-2].ui-dialog .ui-dialog-title {
    display:none;
}

In Google Chrome, you can know which aria-labelledby value to use by right-clicking on the titlebar and choosing Inspect . 在Google Chrome浏览器中,您可以通过右键单击标题栏并选择Inspect来知道要使用哪个aria-labelledby值。 Carefully study the HTML in the left-hand pane, experiment with unchecking/changing CSS values in the right-side pane. 仔细研究左侧窗格中的HTML,并尝试在右侧窗格中取消选中/更改CSS值。

The triangle at the bottom is caused by the ::after pseudo element on .ui-resizable-handle .ui-resizable-s . 底部的三角形是由.ui-resizable-handle .ui-resizable-s上的::after伪元素引起.ui-resizable-handle .ui-resizable-s You can see I was trying to style it, but I will leave that for you to figure out (or ask another SO question). 您可以看到我正在尝试对其进行样式设置,但我将留给您解决(或询问另一个SO问题)。

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

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