繁体   English   中英

在CSS中设置背景图片

[英]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(或您喜欢的浏览器中的任何其他开发人员工具)进行了检查?

  • 您的div完全显示吗?
  • 班级设置正确吗?
  • 后台属性会发生什么?

为什么要使用float AND position:fixed? float:left不执行任何操作。

顺便说一句,我总是使用单引号,使用它们就好了:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM