簡體   English   中英

CSS背景圖片未顯示IE8

[英]CSS Background image not showing IE8

我有以下CSS代碼

#gel{position:absolute; width:20px; height:22px; margin-left:5px; color:#FF0000;background:url('../images/GEL-CURENCY.jpg') repeat-x;background-color:transparent;}

這是我的劇本

document.getElementById("small_txt_container_2").innerHTML = '<span id=\"gel\"></span>';

在IE 8中無法正常工作,請幫助我解決此問題

如果問題僅在IE8中,則在<head>包含此邏輯

<!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

innerHTML是指HTML標記內的內容,而不是標記本身。 查看此示例,它將幫助您了解如何使用純JS在頁面中添加新的<span>

(function(){   
    // 1- Establish new element
    var newItem = document.createElement('span');

    // 2- Add className
    newItem.className = 'gel';

    // 3- Put content into <span> tags
    newItem.innerHTML = 'stuff inside the brackets';

    // 4- Tell your program to put the span just after an item with your-ID-here
    document.getElementById('your-ID-here').appendChild(newItem);           
})();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM