English 中文(简体)
创立一个神学院。 Button, 附有图像档案
原标题:Creating an instance of goog.ui.Button with an image file

谷歌关闭图书馆的Im相对新,而我目前的障碍是,正在形成一个带子,在方案上树立形象(而不是文字)。 我曾尝试增加一个 im子,作为纽芬兰文的内容:

var image = goog.dom.createDom( img , {  src  :  foo.png  });
var button = new goog.ui.Button(image);

然而,尽管一个空白的纽子确实使网页上没有图像。 对生成的超文本的检查显示的是无内容的 but子。

I ve also considered adding a style attribute that specifies background-image. However, it s not clear to me how to accomplish this through the Button API.

任何关于如何实现这一目标的想法或实例? 给予帮助。

EDIT:在我获得Dave Paroulek援助后,我就此达成了解决办法:

var button = new goog.ui.CustomButton();
button.render(goog.dom.getElement( button-row ));
var style = button.getElement().style;
style.backgroundImage =  url(foo.png) ;
style.backgroundPosition =  center center ;
style.backgroundRepeat =  no-repeat ;
最佳回答

习俗似乎在发挥作用:

var image = goog.dom.createDom( img , {  src  :  /images/foo.png  });
var button = new goog.ui.CustomButton(image);

我不明白为什么它与Button公司合作,但注意到Button公司提供<条码>和>;Button>和Button提供数条<条码>和div>有些内容,如带子,因此可能与它有某种关系?

Also, if you want to use background-image, then you can try this:

var div = goog.dom.createDom( div , {  class  :  icon goog-inline-block  });
span = goog.dom.createDom( span , {  style :  vertical-align:middle }, 
                               Button with css image );

button = new goog.ui.CustomButton([div, span]);
var btn2 = goog.dom.$( button2 );
button.render(btn2);

之后,添加如下内容:

.icon {
  height: 16px;
  width: 16px;
  margin: 0 1px;
  background-image: url(/images/foo.png);
  background-repeat: no-repeat;
  vertical-align: middle;
}
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签