[英]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.