如何在SHADOWBOX中声明div的CSS属性?

时间:2014-09-04 14:18:03

标签: javascript jquery html css shadowbox

我创建了一个使用shadowbox打开div的代码,但是我无法为该Div设置CSS属性。这是我的代码。

<style>
.h2class {
    font-family:'Century Gothic';
    font-weight:lighter;
    color:white;
    padding-left:10px;
}
.DivClass1 {
    display:none;
    background-image:url(~/Images/Image1.jpg);
    background-repeat:no-repeat;
    background-size:cover;

}
</style>
<script>
$(document).ready(function () {
            $(function () {
                Shadowbox.init({
                    skipSetup: true
                });

                $('#Link1').click(function () {
                    var content = $('#Div1').html();
                    Shadowbox.open({
                        content: content,
                        player: 'html',
                        displayNav: false,
                        height: 500,
                        width:400
                    });
                });
</script>
<div id="Div1" class="DivClass1">
                <h2 class="h2class">Hello/h2>
            </div>
<a id="Link1" href="#">Click Me</a>

我需要为Div1提供背景图片或背景颜色。请帮忙!!

2 个答案:

答案 0 :(得分:0)

只需将css添加到Div1中:

#Div1{
    background: #CCCCCC;
}

答案 1 :(得分:0)

这是因为Shadowbox只使用#Div1的内容,而不是它的风格。我不熟悉shadowbox,但是Shadowbox.open中可能还有另一个配置项,它可以让你设置div的样式。