简体   繁体   English

涉及固定容器的位置元素

[英]Position elements involving a fixed container

I'm trying to recreate a site-wide announcement similar to yours truly, stackoverflow. 我正在尝试重新创建一个类似于您的站点范围的公告,这确实是stackoverflow。

http://jsfiddle.net/cuMDM/14/ http://jsfiddle.net/cuMDM/14/

I'm having two issues: 我有两个问题:

(1) I can't get the outer div element to appear below the announcement container. (1)我无法使外部div元素出现在公告容器下方。

(2) I want the announcement container element and the outer div element to be of the same width and both centered in the page. (2)我希望公告容器元素和外部div元素具有相同的宽度,并且都位于页面的中心。

Any help would be greatly appreciated. 任何帮助将不胜感激。

The position:fixed on your announcement container means that both it and the outer container will have their top position at 0. You can add a margin or a position to the outer container to change this. 在公告容器上的position:fixed意味着它和外部容器的顶部位置均为0。您可以在外部容器上添加边距或位置来更改此位置。

The announcment container already has a width of 100%. 公告容器的宽度已经为100%。 Are you opposed to putting width:100% on the outer container, and then centering any content for it that you want using some other technique? 您是否反对将width:100%放在外部容器上,然后使用其他方法将要容纳的内容居中放置?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM