[英]Set Background image in CSS
我在JavaScript&CSS中有以下代码来创建div并设置bg图像:
var incrementEnabled = document.createElement('div');
incrementEnabled.className = "SchedMainCtrlIncrementBtn_En";
this.divElt.appendChild(incrementEnabled);
.SchedMainCtrlIncrementBtn_En {
background-color: white;
float:left;
position: fixed;
width:230px;
height:65px;
top:125px;
left:360px;
background:url("../images/icons/IcnListAddRecipient_En.png") no-repeat center;
网址路径也正确,但未设置图片。
谢谢
斯内哈
您不应使用url("../images/icons/IcnListAddRecipient_En.png")
而应使用url("../images/icons/IcnListAddRecipient_En.png")
url(../images/icons/IcnListAddRecipient_En.png)
以此替换css,希望问题能够解决
.SchedMainCtrlIncrementBtn_En {
background-color: white;
float:left;
position: fixed;
width:230px;
height:65px;
top:125px;
left:360px;
background:url(../images/icons/IcnListAddRecipient_En.png) no-repeat center;
您是否使用Firebug(或您喜欢的浏览器中的任何其他开发人员工具)进行了检查?
为什么要使用float AND position:fixed? float:left不执行任何操作。
顺便说一句,我总是使用单引号,使用它们就好了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.