如何使用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>
答案 0 :(得分:1)
我刚刚玩了一点CSS,并得到了你想要的效果:
<强> Working Example 强>
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 */
}