开发者

jQueryUI: Overlay, like on the themeroller page

I am trying开发者_Go百科 to figure out how to do the overlay like on the themeroller page: http://jqueryui.com/themeroller . I tried looking at the source, but it doesn't seem like the theme is applied through any jquery...


I think they are just trying to show you the ui-widget-overlay and ui-widget-shadow class of jqueryui css framework on the themeroller page.

http://jqueryui.com/docs/Theming/API#Overlay_.26_Shadow

I just tried to copy the html and css to jsfiddle and it simply works. http://jsfiddle.net/Fcs9y/

That's nothing to do with the UI widgets I presume.


It's kind of a hidden function, but if you add modal: true to your parameters (like width: or buttons:), it creates the same effect, blocking out the background.


#overlaySpan {
 font:Arial, Helvetica, sans-serif;
 font-size:14px;
 font-weight:bold;
 color:white;
 background: url(../images/icons/notifications/close.png) no-repeat;
 cursor:pointer;
 position:absolute;
 top:-8px;
 right:-8px;
 width:20px;
 height:20px;
 padding:0;
 text-align:center;
 z-index:102;

}
#overlayBack {
    margin:0;
    background-color:black;
    position:fixed;
    top:0;
    left:0;
    padding:0;
    width:100%;
    height:100%;
    z-index:99;
    filter:alpha(opacity=70);
    -khtml-opacity: 0.7;
    opacity: 0.7;
    -moz-opacity:0.7;
}
#overlayDiv {
    -moz-border-radius: 4px;
    border-radius: 4px;
    display:none;
    background-color:white;
    position: fixed;
    top: 50%;
    left: 50%;
    padding:2px;
    z-index:101;
    width:500px;
    padding:10px;
}
#overlayDivBack {
    -moz-border-radius: 4px;
    border-radius: 4px;
    background-color:black;
    position: fixed;
    top: 50%;
    left: 50%;
    padding:2px;
    z-index:100;
    width:520px;
    padding:10px;
    filter:alpha(opacity=40);
    -khtml-opacity: 0.4;
    opacity: 0.4;
    -moz-opacity:0.4;
}

This is my css. I'm using my own overlay.

<div id="overlayBack"></div>
<div id="overlayDiv"><span id="overlaySpan"></span></div>
<div id="overlayDivBack"></div>

Just giving you some idea to figure it out. Simply use jquery to show and hide them. Its all about z-index's.


Overlay on most pages is fixed positioned element (div) with width and height set to 100% or some pixel values. Then it has color and opacity - thats it.

If you want to know exactly on the themeroller page, check in Firebug or Inspect Element with a Chrome. I can see that they are using some -mor-border-radius and -webkit-border-radius properties for border.


Works like this: from js file named: http://static.jquery.com/ui/themeroller/scripts/app.js method name: themeGalleryBehaviors

// loading and viewing gallery themes
$('#themeGallery a')
    .bind('click', function() {     
        updateCSS(hash.clean(this.href.split('?')[1]));
        hash.updateHash(hash.clean(this.href.split('?')[1]), true);
        return false;
    })

the call to updateCSS method appends a

function updateCSS(locStr){
    //once 1.6 final is ready: $("head").append('<link href="/themeroller/css/parseTheme.css.php?'+ locStr +'" type="text/css" rel="Stylesheet" />');
    $("link[href*=parseTheme\\.css\\.php]:last").after('<link href="/themeroller/css/parseTheme.css.php?'+ locStr +'" type="text/css" rel="Stylesheet" />');

This in its turn does some overlaying magic. I didn't follow the code all the way through, I hope I did enough.


This does the trick:

JavaScript:

$("#element-to-be-dialogged").dialog({
    ...
    dialogClass: 'dialog-with-rounded-shadow'
    ...
});

CSS:

.dialog-with-rounded-shadow {
    box-shadow: 0 0 0 10px rgba(0,0,0,0.2);
}

JSFiddle: http://jsfiddle.net/martinba/8zwLqodm/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜