Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未使用jQuery加载加载转盘背景图像_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript 未使用jQuery加载加载转盘背景图像

Javascript 未使用jQuery加载加载转盘背景图像,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,我试图使用jquery的.load函数将导航栏+旋转木马插入多个html页面-我的问题是背景照片似乎没有显示出来 这是我试图用jQuery的.load加载的“header.html”文件的一部分: <header id="myCarousel" class="carousel slide"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-targ

我试图使用jquery的.load函数将导航栏+旋转木马插入多个html页面-我的问题是背景照片似乎没有显示出来

这是我试图用jQuery的.load加载的“header.html”文件的一部分:

<header id="myCarousel" class="carousel slide">
    <!-- Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>
    <!-- Wrapper for slides -->
    <div class="carousel-inner">
        <div class="item active">
            <div class="fill" style="background-image:url('img1.jpg');"></div>
            <div class="carousel-caption">
            </div>
        </div>
        <div class="item">
            <div class="fill" style="background-image:url('img2.jpg');"></div>
            <div class="carousel-caption">
            </div>
        </div>
        <div class="item">
            <div class="fill" style="background-image:url('img2.jpg');"></div>
            <div class="carousel-caption">
            </div>
        </div>
    </div>
    <!-- Controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
        <span class="icon-prev"></span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
        <span class="icon-next"></span>
    </a>
</header>
css(链接到包括导航栏/旋转木马在内的所有页面):


你的CSS在哪里?如果这些div没有内容,并且在CSS中没有指定
高度,那么它们将不会显示。刚刚添加!当我不使用jQuery load时,背景照片css工作正常,但我不想在我的所有页面中都包含相同的navbar/carousel代码。您包括
navbar.html
not
header.html
对不起,文件名为navbar.html。它包括导航条形码和旋转木马代码。为了避免混淆,我将其重命名为header.html。代码正成功加载到我的其他页面中,因为出现了导航栏,但是问题仍然在于背景imagestry使用图像的绝对路径。
$(function() {
    $("#header").load("header.html", function() {
        $('.carousel').carousel({
            interval: 5000 //changes the speed
        })
    });
});
header.carousel {
    height: 50%;
}

header.carousel .item,
header.carousel .item.active,
header.carousel .carousel-inner {
    height: 100%;
}

header.carousel .fill {
    width: 100%;
    height: 100%;
    background-position: center;
    background-size: cover;
}