0

如何使用 jQuery 手风琴并在流入标题的内容中添加背景图像?我已经能够使标题透明,但我似乎无法将它们组合起来。我不知道这是否可能,因为它们是分开的h3,并且divs.

<style type="text/css">
html,body{
height: 100%;
}
.ui-accordion-content{
background:url('{{ url_for('static',filename='img/building_img/4/bg4_black.jpg') }}');
background-size: cover;
background-repeat: no-repeat;
}
</style>


<div id="accordion2">
  <h3>building.name</h3>
  <div>
<p>Mauris mauris ante, blandit et, ultrices a, suscipit eget.
Integer ut neque. Vivamus nisi metus, molestie vel, gravida in,
condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros.
Nam mi. Proin viverra leo ut odio.</p>
</div>
</div>

<script>
$(function(){
$( "#accordion2" ).accordion({
heightStyle: "fill"

});
$(window).resize(function(){
    // update accordion height
    $( "#accordion2" ).accordion( "refresh" )
});
})
</script>
4

1 回答 1

1

我只是玩了一下 CSS,得到了你想要的效果:

工作示例

html, body {
    height: 100%;
}
.ui-accordion .ui-accordion-content {
    background: url('http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png'); 
    background-repeat: repeat; /* changed the background for demo purposes only*/
    position:relative;
    top:-40px;
    z-index:1; /* used position and z-index to get the header to overlap the content */
    padding-top:20px; /* keep the text below the header */
}
#accordion2 h3{
    background:#fff url('http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png');
    background-repeat: repeat; /* use the same background img for the header and content, but be sure to add a color to the header */
    position:relative;
    z-index:2; /* used position and z-index to get the header to overlap the content */
}
于 2013-08-22T14:53:16.557 回答