保证金自动变为负值 [英] Margin auto goes to negative values

查看:109
本文介绍了保证金自动变为负值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的边距有问题:自动-垂直居中 #something { width: 97%; height: 300px; border: 1px solid red; position: absolute; top: 0; bottom: 0; margin: auto; }

I have problem with margin: auto - vertical centering #something { width: 97%; height: 300px; border: 1px solid red; position: absolute; top: 0; bottom: 0; margin: auto; }

此功能在每种现代浏览器中均有效-当页面(视口)高于300px时,其垂直居中,但是,当页面(视口)低于300px时,其停止工作,除了在firefox中...在firefox中运行在其他浏览器中,它很好(也许是不好的功能,但它的逻辑功能)在视口顶部的居中元素分配器顶部.

This work in every modern browser - when the page (viewport) is higher then 300px, its centered vertically, but, when the page(viewport) is lower then 300px stopped it works everywhere except in firefox... In firefox run it good (maybe it is bad functionalitiy, but its logical functionality) in other browsers the top of centered element disappers in the top of viewport.

http://jsfiddle.net/LhHed/2/这是上帝的例子-当您调整结果窗口大小,在firefox中可以很好地工作,而在其他浏览器中则不能.可能的tu修复了吗?还是firefox的不良功能?

http://jsfiddle.net/LhHed/2/ Here is god example - when you resize result window, in firefox work it well, in others browsers not. Is posible tu fix it? Or its bad functionality of firefox?

实时示例 http://dev8.newlogic.cz

推荐答案

当我对主体元素使用position: relative时,我在浏览器中解决了该问题.现在,它也可以在firefox和其他浏览器中使用. http://dev8.newlogic.cz

I removed the problem in browsers, when i use position: relative to the body element. Now its working in firefox and in other browser too. Live example on http://dev8.newlogic.cz

这篇关于保证金自动变为负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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