[英]background-image: url not working properly
我遇到的問題是,當我使用javascript獲取另一個HTML文件中的HTML文件時,背景圖像變為不可見。 但是,當我使用背景圖像打開文件時,該圖像可見。
為了使這一點易於理解,我想使用javascript在first.html中包含second.html (帶有背景圖像),而圖像不可見。
First.html(主要)
<html>
<head>
<script>
$(function(){
$("#second").load("second.html");
});
</script>
</head>
<body>
<div id="second"></div>
</body>
</html>
Second.html(帶圖片)
<body style="background-image: url('img/dashboard-layout.png'); background-repeat: no-repeat; background-color: #303032;">
<!--Code goes here-->
</body>
這是我的工作示例first.html
<html>
<head>
<script>
$(function(){
$("#second").load("second.html");
});
</script>
</head>
<body>
<div id="second" style="height:100px;width:100%;"></div>
</body>
second.html
<div style="height:100px;width:100%;background-image: url('http://blogs.atlassian.com/wp-content/uploads/01-new-icons.png'); background-color: #303032;">
請注意,div的默認高度為0px,您需要設置div的高度才能使用此功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.