Button Backgroud-Image toStaticHtml问题 [英] Button Backgroud-Image toStaticHtml Problem

查看:75
本文介绍了Button Backgroud-Image toStaticHtml问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,在使用内联css样式设置按钮的背景图像时遇到问题。我不知道它为什么不起作用。这是代码。



<预类= "prettyprint">

功能setSrc(){
的document.getElementById(QUOT; theText")。innerHTML的=文档。 getElementById(" theText")。innerHTML + window.toStaticHTML
(" button id ='buttonBox'style ='width:185px; height:274px; margin-left:15px; margin-right:15px ;边距:0像素;边距:0像素;背景图像:网址(C:\Users\Anton\ice.jpg)不重复;背景位置:中心;'>< /按钮> ;");
var urll = document.getElementById(" theText")。innerHTML;
var msgBox = new Windows.UI.Popups.MessageDialog(urll," MessageBox");

msgBox.showAsync();
}


注意我已经放入一个消息框以查看输出的确切内容看来背景图像被彻底撕掉了!我不明白为什么,mebay你们可以对它有所了解,我已经阅读了关于toStaticHtml函数的信息,并且说b $ b允许背景图像。

解决方案


您好Anton,


您无法在Metro中使用文件路径风格应用" C:\Users\Anton\ice.jpg"


包括所述图像作为资产在项目中,并引用它的方式,而不是&NBSP。





-Jeff


Hi guy's having a problem getting the background image of a button to be set using an inline css style. I have no idea why it is not working. Here is the code.

function setSrc() { document.getElementById("theText").innerHTML = document.getElementById("theText").innerHTML + window.toStaticHTML ("<button id='buttonBox' style='width:185px; height:274px; margin-left:15px; margin-right:15px; margin-top:0px; margin-bottom:0px; background-image:url(C:\Users\Anton\ice.jpg) no-repeat; background-position:center;'></button>"); var urll = document.getElementById("theText").innerHTML; var msgBox = new Windows.UI.Popups.MessageDialog(urll,"MessageBox"); msgBox.showAsync(); }

Note I have put a messagebox in to see exactly what is being outputted and it appears that background-image is being ripped out completely! have no idea why, mebay you guys can shed some light on it, I have read about the toStaticHtml function and it says that background-image is allowed.

解决方案

Hi Anton,

You cannot use file paths in Metro style apps "C:\Users\Anton\ice.jpg"

Include the image as an asset in your project and reference it that way instead. 

-Jeff


这篇关于Button Backgroud-Image toStaticHtml问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆