透明且可扩展的包装div,怎么样?
我制作了一张图片来更容易地解释我的追求:
图片插图 http://bayimg .com/image/eabahaaci.jpg
我已经阅读了有关该主题的其他一些问题,但我不确定这些解决方案是否适合我,因为我的 div 需要可扩展并随着添加更多内容而增长。
有谁知道如何以简单的方式实现这一点?
I made an image to easier explain what Im after:
Image Illustration http://bayimg.com/image/eabahaaci.jpg
Ive read some other questions on the subject but Im not sure the solutions will work for me because my div needs to be expandable and grow as more content is added.
Does anyone know how to accomplish this in a simple way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将部分透明的
.png
图像设置为#content-wrap
部分的背景,并为 div 设置纯色背景(我使用了#main-content
和#footer
,但它们具有相同的样式,因此您可以使用#content-wrap div
并稍微缩短 css 。...如果您知道您的受众将使用 FF3.x(可能还有基于 webkit 的浏览器),您可以使用
background-color: rgba(0,0,0, 0.6);
来定义背景颜色(红色=0、绿色=0、蓝色=0、alpha=0.4 或 40% 不透明(或 60% 透明)) - 值介于0
(完全透明)和1
(完全不透明)。)使用
rgba
作为颜色可以防止在尝试使子级可见时使用opacity
使父div透明的问题。 但当然,由于浏览器的采用,它的使用受到限制......我的网站上的工作演示已经结束: http://www.davidrhysthomas.co.uk/so/transparent.html" rel="nofollow noreferrer">http:// /www.davidrhysthomas.co.uk/so/transparent.html
This sets a partially-transparent
.png
image as the background for the#content-wrap
section, with a solid color background for the divs (I've used#main-content
and#footer
, but they've got the same style so you could just use#content-wrap div
and shorten the css a little....if you know that your audience will be using FF3.x (and probably webkit based browsers), you could use
background-color: rgba(0,0,0, 0.6);
to define the background-colour (red=0, green=0, blue=0, alpha=0.4 or 40% opaque (or 60% transparent) -the values being between0
(entirely transparent) and1
(entirely opaque).)Using the
rgba
for colour prevents problems from usingopacity
to make the parent div transparent, while trying to make the children visible. But it's got limited use because of browser adoption, of course...A working demo is over at my site: http://www.davidrhysthomas.co.uk/so/transparent.html
您将需要一个 1 像素高的图像切片来实现透明度
一个用于底部的圆形绳索,
我已将宽度和边距调高。 您应该自己输入正确的尺寸
You will need an 1px high image slice for the transperncy
and one for the rounded corders at the bottom
I have made the widths and margins up. You should put in the right sizes yourself