简体   繁体   English

jQuery基本对话框小部件中的自定义样式

[英]custom styles in jquery basic dialog widget

Kinda' a newbie here... 金达是这里的新手...

I am trying to change the basic format of the box in the jQuery dialog widget. 我正在尝试在jQuery对话框小部件中更改框的基本格式。

I presume that would involve making changes or overrides to the theme. 我认为这涉及对主题进行更改或替代。

That lead me to the themeroller. 那把我引向了themeroller。

I am not trying to "re-invent the wheel," just tweak the characteristics (font size, placement of the dialog box, selecting an icon, etc.) 我不是在尝试“重新发明轮子”,只是调整特征(字体大小,对话框的位置,选择图标等)。

Given that, do I need to build a custom theme, or can I more easily make small changes? 鉴于此,我是否需要构建自定义主题,还是可以更轻松地进行小的更改? And if so, how? 如果是这样,怎么办?

I cannot figure out how to use the themeroller to meet my needs. 我无法弄清楚如何使用themeroller来满足我的需求。

Is there a good source or book that would help a kinda' newbie like me? 有没有很好的资源或书籍可以帮助像我这样的新手?

Yes, I have been here: 是的,我去过这里:

....jquery-ui/getting-started/

....jquery-ui/theming/

But that takes me more into the weeds that I want to go at this point. 但这使我更多地进入了我现在想去的杂草。 (Or, is that a necessity at this point?) (或者,此时是否有必要?)

(I have found several references here, but none that I know how to apply to my situation.) (我在这里找到了几处参考,但我不知道如何适用于我的情况。)

My configuration: 我的配置:

I am using the "default functionality" found here: 我正在使用此处的“默认功能”:

....jqueryui.com/dialog/

with jquery-1.10.1 与jquery-1.10.1

I had to use that version to make it compatible with the version of fancybox that I am using (2.1.5): (The compatibility issue is a real pain for me.) 我必须使用该版本以使其与我使用的fancybox版本(2.1.5)兼容:(兼容性问题对我来说确实是一个痛苦。)

this is the code I am using for the jQuery widget: 这是我用于jQuery小部件的代码:

    <!-- basic alert:  -->
    <script type="text/javascript" src="fbox2/lib/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.js"></script>
    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
    <!-- basic alert  -->

Currently, my code to call the widget looks like this: 目前,我调用小部件的代码如下所示:

JS: JS:

    function dopopup()  {
        $("<div title='Basic dialog onclick'>Test message <b>bolded</b></div>").dialog();
    return
    }

html: HTML:

    <a href="#" onclick="dopopup()">here</a><p>

Can you please lead me in the right direction on this issue? 您能否在这个问题上引导我正确的方向?

Thank you. 谢谢。

What will probably help you here is either Firebug http://getfirebug.com/ which runs on Mozilla Firefox or use the Chrome Development Tools which come bundled natively in any Chrome variant. 在这里可能会为您提供帮助的是可以在Mozilla Firefox上运行的Firebug http://getfirebug.com/或使用任何Chrome变体中都附带的Chrome开发工具。 Then you can "Inspect" the elements you wish to modify via CSS. 然后,您可以“检查”要通过CSS修改的元素。 By Inspect I mean you browse through the constituent elements and observe which CSS styles apply to them. 通过Inspect,我的意思是您浏览组成元素并观察哪些CSS样式适用于它们。

This is made incredibly easy with the tools mentioned above, allowing you to modify the properties on-the-fly to test what looks good and works. 使用上面提到的工具,这变得非常容易,使您可以即时修改属性以测试看起来不错并可以工作的属性。

When/if satisfied with a particular setting of a property, you would "override" the pertinent rule by declaring an updated rule/property to that found in the default jQuery-ui theme by including your own CSS file or inline <style> declarations later on in the page. 当/如果对属性的特定设置感到满意,则可以通过声明一个更新后的规则/属性来声明默认jQuery-ui主题中的规则/属性,从而“覆盖”相关规则,方法是稍后包含您自己的CSS文件或内联<style>声明在页面上。

As an example, here is a vanilla version of the dialog and theme: Demo: http://jsfiddle.net/robschmuecker/3uKnt/ 例如,以下是对话框和主题的原始版本:演示: http : //jsfiddle.net/robschmuecker/3uKnt/

and after some "inspecting" I have modified only a few choice rules to give it a totall different look. 经过一些“检查”后,我仅修改了一些选择规则,使其外观完全不同。

CSS: CSS:

.ui-widget {
    font-family: courier;
}
.ui-dialog .ui-dialog-title {
    font-size: 8px;
}
.ui-widget-content {
    background-color: #616DFF;
}
.ui-widget-header .ui-icon {
    background-image: url("http://www.famfamfam.com/lab/icons/silk/icons/bell.png");
    background-position:0;
}

Demo: http://jsfiddle.net/robschmuecker/3uKnt/1/ 演示: http : //jsfiddle.net/robschmuecker/3uKnt/1/

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

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