[英]background-image: url not working properly
The problem I am encountering is that when I use javascript to get the html file inside another html file, the background image turns invisible. 我遇到的问题是,当我使用javascript获取另一个HTML文件中的HTML文件时,背景图像变为不可见。 But when I open the file with the background image the image is visible.
但是,当我使用背景图像打开文件时,该图像可见。
To make this understandable, I want to include second.html (with background image) in first.html using javascript without the image being invisible. 为了使这一点易于理解,我想使用javascript在first.html中包含second.html (带有背景图像),而图像不可见。
First.html (main) First.html(主要)
<html>
<head>
<script>
$(function(){
$("#second").load("second.html");
});
</script>
</head>
<body>
<div id="second"></div>
</body>
</html>
Second.html (with image) Second.html(带图片)
<body style="background-image: url('img/dashboard-layout.png'); background-repeat: no-repeat; background-color: #303032;">
<!--Code goes here-->
</body>
This is my working example first.html 这是我的工作示例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 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;">
Note that div has default height = 0px you need to set height for divs to work this eg. 请注意,div的默认高度为0px,您需要设置div的高度才能使用此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.