CSS在多种分辨率之间绝对定位
我网站的主要部分包含多个 DIV,其中一个位于带有 Flash 的“背景”(z-index:-1;) 中。除了该 DIV 之外,我还有另一个 DIV(仅文本)需要与 Flash DIV 重叠。我不能让它们并排放置,因为 Flash 的宽度为 100%。所以我做了一些与 CSS 绝对定位重叠的工作。但是,当调整浏览器宽度或高度时,这种情况就会中断。
有哪些选项可以将第二个 DIV 保留在屏幕的特定部分?
更新 - 添加代码
<div id="yjsg2">
<div id="adv1" class="yjsgxhtml" style="width:72.00%;">
<div id="adv2" class="yjsgxhtml" style="width:28.00%;">
</div>
CSS 看起来像
#adv1 {width:100% !important;}
#adv2 {position:absolute; left:665px; top:110px;}
这样,它的代码相当简单,这完全取决于它的位置。
The main section of my web site contains multiple DIVs, one of which sits in the "background" (z-index:-1;) with Flash. Outside of that DIV, I have another one (just text) that needs to overlap with the Flash DIV. I can't have them sit side-by-side because the Flash has a width of 100%. So I've done some overlap with CSS absolute positioning. However, this breaks when the browser width or height is adjusted.
What are the options for keeping the second DIV in a very specific part of the screen?
UPDATE - code added
<div id="yjsg2">
<div id="adv1" class="yjsgxhtml" style="width:72.00%;">
<div id="adv2" class="yjsgxhtml" style="width:28.00%;">
</div>
The CSS looks something like
#adv1 {width:100% !important;}
#adv2 {position:absolute; left:665px; top:110px;}
So its fairly simple code, it's all a matter of the positioning of it all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果可以的话,将容器元素设置为具有相对位置,因为如果给定除静态(默认)以外的任何位置,则绝对定位的元素将根据其与其父级的相对位置进行定位
If you can, set the container element to have relative position as absolutely positioned elements are positioned based on their relative position to their parent if given any position other than static (default)
CSS 绝对定位和可调整大小的页面不能很好地混合,因为盒子模型对此没有提供很好的支持(对此有很多抱怨/抱怨)。一种选择是基于 javascript 的布局管理器,例如 http://layout.jquery-dev.net/
CSS absolute positioning and resizable pages do not mix well, as the box model does not provide great support for this (There are numerous rants / complaints about it). One option is javascript based layout managers like http://layout.jquery-dev.net/