在< div>中创建孔元件 [英] Creating a hole in a <div> element

查看:116
本文介绍了在< div>中创建孔元件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

中的孔 - - 可以显示背景的元素或方法,仅适用于特定区域,位于< div> ; 元素。

Definition of Hole in a div - An element or a method by which you can show the background, only for a particular area, behind the content of a <div> element.

推荐答案

更大的问题实际上不是你想要看到的元素的背景(这只是背景颜色:透明),而是它的祖先元素。例如,如果包含元素具有白色背景,则具有背景颜色:透明的div仍然看起来像是具有白色背景。最好的方法是在页面中的较低级别定义背景颜色。例如,如果您想通过div#see-through查看,并且它是div#content的一个孩子,它在div#header和div#footer之间,您可以给#header和#footer背景颜色,但将#content定义为透明。然后为#see-through的各个兄弟元素分配背景颜色。还有一件事:记住在定义透明元素时,即使一个透明元素可以有彩色边框,这意味着您可以在不添加额外元素的情况下进入中间点。

The larger issue is not actually the background of the element you want to see through (which would just be background-color:transparent) but instead its ancestor element(s). For instance, a div with a background-color: transparent is still going to look as if it has a white background if its containing element has a white background. The best approach then is to define the background colors at lower levels in the page. For instance, if you want to see through div#see-through and it's a child of div#content which is in between div#header and div#footer, you could give #header and #footer background colors but define #content as transparent. Then assign background colors to the individual sibling elements of #see-through. One more thing: it might be helpful to remember when defining the transparent element that even a transparent element can have "colored" borders, meaning that you might be able to reach into in-between spots without adding extra elements.

这篇关于在&lt; div&gt;中创建孔元件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆