2014-09-04 35 views
0

我已经创建了一个使用shadowbox打开div的代码,但我无法为该div设置CSS属性。这是我的代码。如何在SHADOWBOX中声明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构成。请帮忙!!

回答

0

单纯以Div1构成添加CSS为:

#Div1{ 
    background: #CCCCCC; 
} 
+0

我试过了。我尝试了所有声明CSS的方法(使用id,class,inline,external),但我发现没有改变。为什么? – Gogul 2014-09-04 14:27:59

0

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

+0

它看起来像没有选择这样做...您可能需要使用不同的插件来完成这项工作。 – evilunix 2014-09-04 14:33:00