以下示例中,当5,6,7这几个输入框获得焦点时,其父元素会整体上浮,如何禁止这种情况。
- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <div style="height:150px;border:solid 1px blue;overflow:hidden;"> 第1个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> 第2个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> 第3个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> 第4个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> 第5个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /> 点击这个textbox,或者通过tab键focus到6、7两个textbox, 就会发现整个div的内容会上浮, 而且即使刷新页面, 也不能恢复到原始状态。 <span style="color:red">如何阻止这种上浮?</span><br /> 第6个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> 第7个<input type="text" style="height:20px;border:solid 1px green;margin:5px;" /><br /> </div> </body> </html>
------解决方案--------------------
删除567或禁用567或overflow:auto;
------解决方案--------------------
高度设置有问题
总高度150px 里面内容是140px+margin的35px
超出了
------解决方案--------------------
这种效果很不友好