jQueryUI CSS包含图像

时间:2011-07-12 20:43:51

标签: jquery jquery-ui base64

我正在使用jQuery UI和jQuery。我对jQuery UI文件进行了修改,因此所有图像都是在CSS文件中编码的。这是因为特殊要求所有图像和文件应仅在一个文件上。

例如:

.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff 
       url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAABkCAYAAAD0ZHJ6AAAAeUlEQVRoge3OM
          QHAIBAAsV/nh8J
          DDfAkCjImpn5HvbfDpwIVoKVYCVYCVaClWAlWAlWgpVgJVgJVoKVYCVYCVaClWAlWAlWgpVgJVgJ
          VoKVYCVYCVaClWAlWAlWgpVgJVgJVoKVYCVYCVaClWAlWAlWgpVgJVgJVhtqiwTEKTLXTgAAAABJ
          RU5ErkJggg==
       ) 
       50% 50% repeat-x; color: #222222; 
       }

但是当我使用对话框时,css未正确加载。例如,当我这样做时:

    $("#dialog").dialog();

显示一个对话框,但不显示对话框标题和底部。

1 个答案:

答案 0 :(得分:0)

不确定如何将背景图片转换为base64,但在this demo我编码的.ui-widget-content.ui-widget-header背景图片似乎在Chrome 14中正常工作。请注意标题和底部有不同的背景图像(虽然我还没有完成这个演示的底部图像)。

修改:代码重复此处以防jsFiddle消失:

HTML

<div id="dialog"></div>

的JavaScript

$('#dialog').dialog();

注意:需要jQuery和jQueryUI

CSS

.ui-widget-content {
    border: 1px solid #aaaaaa; background: #ffffff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAABkCAYAAABHLFpgAAAAIUlEQVQYlWP48ePHfyYGBgaGIUT8//8fO5cSFn6J4UQAAJSgIpAFCJPdAAAAAElFTkSuQmCC) 50% 50% repeat-x; color: #222222; 
}

.ui-widget-header {
    border: 1px solid #E78F08;
    background: #F6A828 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAABkCAYAAABwx8J9AAAOeUlEQVR4nO2dW44buxFAybH2k40ESNaZBSRZVr5i4CYzzIfdcU+5nmz2WEO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