2013-04-21 55 views
0

我有以下问题: 我目前正在使用html和css制作一个网站。我已经构建的背景是这样的:HTML问题与图像

<!DOCTYPE html> 
<html> 
    <head> 
    <style> 
     div.background { 
     width: 500px; 
     height: 250px; 
     background: url(klematis.jpg) repeat; 
     border: 2px solid black; 
     } 
     div.transbox { 
     width: 400px; 
     height: 180px; 
     margin: 30px 50px; 
     background-color: #ffffff; 
     border: 1px solid black; 
     opacity:0.6; 
     filter:alpha(opacity=60); /* For IE8 and earlier */ 
     } 
     div.transbox p { 
     margin: 30px 40px; 
     font-weight: bold; 
     color: #000000; 
     } 
    </style> 
    </head> 
    <body> 
    <div class="background"> 
     <div class="transbox"> 
     <p> 
      This is some text that is placed in the transparent box. 
      This is some text that is placed in the transparent box. 
      This is some text that is placed in the transparent box. 
      This is some text that is placed in the transparent box. 
      This is some text that is placed in the transparent box. 
     </p> 
     </div> 
    </div> 
    </body> 
</html> 

,当然,我想提出另外的照片在框中,但你可以通过他们看,你能看到的背景图像,所以画面显得苍白和转运。我怎样才能使图片不同的背景颜色才能看起来坚实?

回答

0

您可以通过在img元素上设置background属性来设置图像的背景。

img { background: black; } 

这将覆盖初始值background: transparent它允许页面背景彪炳如果图像具有透明区域。

+0

我试过了,但没有奏效。任何其他想法? – 2013-04-21 16:08:26

+0

尝试张贴代码和/或网址,说明你实际做了什么,并解释a)你预期会发生什么,b)发生了什么。 – 2013-04-21 16:19:16