简体   繁体   English

绝对定位 <input> 在IE9中使用“left”和“right”不起作用

[英]Absolute positioning <input> with “left” and “right” in IE9 doesn't work

I use a CSS trick where I set position: absolute on an element, and then set like left: 0px; right: 70px 我使用CSS技巧,我在一个元素上设置position: absolute ,然后像left: 0px; right: 70px一样设置left: 0px; right: 70px left: 0px; right: 70px to make sure that the element spans the whole length of the parent, but always leaving 70px space to the right. left: 0px; right: 70px以确保元素跨越父级的整个长度,但始终向右侧留出70px空间。

However, I recently found that this trick does not work in IE9 for text input elements. 但是,我最近发现这个技巧在IE9中不适用于文本输入元素。 The "left" and "right" properties does not alter the default width of the element at all. “left”和“right”属性根本不会改变元素的默认宽度。 Does any one know a workaround for IE9? 有没有人知道IE9的解决方法?

Please see this fiddle , although you have to be viewing it in IE9 to see the effect... 请看这个小提琴 ,虽然你必须在IE9中查看它才能看到效果......

Input elements don't like being stretched like that. 输入元素不喜欢被拉伸。 Put it in a containing <div> , position the <div> , and then use width:100% on the input. 将它放在包含<div> ,定位<div> ,然后在输入上使用width:100%

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

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