2009-06-23 38 views

回答

2
#body {background: transparent url(background/image.png) 0 0 repeat-y; 
} 

#content-wrap {width: 60%; 
       margin: 0 auto; 
       background: transparent url(partially/transparent/60percent-opaque.png) 0 0 repeat; 

} 

#main-content {width: 90%; 
       margin: 1em auto 0 auto; 
       background-color: #fff; 
} 

#footer  {width: 90%; 
       margin: 1em auto 0 auto; 
       background-color: #fff; 
} 

這將設置一個部分透明.png影像爲背景,爲#content-wrap部分,用純色背景的div(我用#main-content#footer,但他們「已經得到了相同的風格,所以你可以只使用#content-wrap div,縮短CSS一點。

<div id="content-wrap"> 
<!-- this is the outer wrapping div --> 

<div id="main-content"> 

<!-- this I'm assuming is the main content portion --> 

</div> 

<div id="footer"> 

<!-- the name explains my assumption, I think... --> 

</div> 

</div> 

body { 
 
    background: #fff url(http://i.stack.imgur.com/9uIxu.png) 0 0 repeat; 
 
} 
 
#content-wrap { 
 
    width: 60%; 
 
    margin: 1em auto; 
 
    padding: 1em 0; 
 
    background-color: rgba(0, 0, 0, 0.3); 
 
    -moz-border-radius: 1em; 
 
    -webkit-border-radius: 1em; 
 
} 
 
#content-wrap div { 
 
    width: 90%; 
 
    margin: 1em auto; 
 
    background-color: #fff; 
 
} 
 
#content-wrap div p { 
 
    margin: 1em 0; 
 
}
<div id="content-wrap"> 
 

 
    <div id="main-content"> 
 

 
    <p>I presume the main content will sit here...</p> 
 

 
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium 
 
     quis, sem. Nulla consequat massa quis enim.</p> 
 

 
    <p>Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean 
 
     vulputate eleifend tellus.</p> 
 

 
    <p>Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. 
 
     Curabitur ullamcorper ultricies nisi.</p> 
 

 
    <p>Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. 
 
     Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit 
 
     cursus nunc,</p> 
 

 
    </div> 
 

 
    <div id="footer"> 
 

 
    <p>This'd be the footer. And so on...</p> 
 

 
    </div> 
 

 
</div>

...如果您知道您的受衆將使用FF3.x(可能基於Webkit的瀏覽器),則可以使用background-color: rgba(0,0,0, 0.6);來定義背景顏色(紅色= 0,綠色= 0,藍色= 0,阿爾法= 0.4或40%不透明(或60%透明)-the值0(完全透明),並1(完全不透明)。)

之間不同於使用opacity使用rgba用於彩色防止問題,使母體股利透明,同時努力讓孩子可見。但它有,因爲瀏覽器的採用,當然的用途有限...

的工作演示結束我的網站:http://www.davidrhysthomas.co.uk/so/transparent.html

+0

怎麼樣的圓角設置在包裝的底部? – 2009-06-23 23:52:24

0

您需要的transperncy 和一個圓形corders的1px的高形象片在底部

.background{ 
    background:url(/image/path); 
} 
.wrapper{ 
    background:url(/image/path/trans.png) repeat-y; 
    width:500px; 
    position:relative; 
} 
.wrapper .bottom{ 
    background:url(path/to/image) no-repeat; 
    position:absolute; 
    bottom:0; 
    left:0; 
    height:20px; 
} 

.inner{ 
    background:#fff; 
    margin:10px; 
} 

我所做的寬度和利潤了。你應該把在正確的大小自己