2007-04-02
不用js也能实现几个未知高度的容器对齐
关键字: 高度对齐css 代码
- /* easy clearing */
- div#content:after { /* overflow:hidden must be in div#content */
- content: '[DO NOT LEAVE IT IS NOT REAL]';
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
- }
- div#content { display: inline-block; }
- /*\*/
- div#content { display: block; }
- /* end easy clearing */
- /*\*/
- #secondaryNavigation,#primaryContent{
- padding-bottom: 32767px !important;
- margin-bottom: -32767px !important; }
- @media all and (min-width: 0px) {
- #secondaryNavigation,#primaryContent {
- padding-bottom: 0 !important;
- margin-bottom: 0!important;
- }
- #secondaryNavigation:before,#primaryContent:before{
- content: '[DO NOT LEAVE IT IS NOTREAL]';
- display: block;
- background: inherit;
- padding-top: 32767px!important;
- margin-bottom: -32767px !important;
- height: 0;
- }
- }
注意:几个容器必须是并行的,并且必须在外层容器上设置 overflow:hidden属性,几个选择器上伪类的定义不可少。
虽然看上去有些杂乱,但如果不用js也能实现几个未知容器高度的自适应 也未尝不是件巧妙的事,更重要的是在ff、ie下均有效,而且屡试不爽。
发表评论
- 浏览: 47266 次
- 性别:

- 来自: 上海

- 详细资料
搜索本博客
我的相册
w3c01
共 46 张
共 46 张
最近加入圈子
链接
最新评论
-
成功的用户体验必须遵循的 ...
是的,真正从用户需求和网站目标开始说起的话,有很多可以说~ 等后面有时间写点更加 ...
-- by tiger.passion -
成功的用户体验必须遵循的 ...
还可以说的更详细点阿!
-- by lxdhdgss -
SEO之网站结构优化
有没有 优化 比较好的 网站例子 共享下
-- by 风雪涟漪 -
SEO之网站结构优化
不错 。学习了。期待有更好的文章
-- by 风雪涟漪 -
Firefox 3 Beta 4已完成测 ...
迫不及待呀
-- by boy in the road






评论排行榜