简体   繁体   English

CSS形式ie7 bug,剩余边距和浮动

[英]CSS form ie7 bug with margin left and float

This css code has troubles for ie7. 这个css代码对ie7有麻烦。 In ie6 is a total absolute mess. 在ie6中是完全绝对的混乱。
The problem is that the input textbox gets bellow label. 问题是输入文本框得到低于标签。 在此输入图像描述 Only work around is to float the div left but has problems then with sizing.. 只有解决方法是将div向左浮动,但是在调整大小时会出现问题。

fieldset.label_side > label {
    width: 100px;
    position: relative;
    float: left;
    left: 0;
    padding: 18px 20px 8px;
    border-right: 1px solid #eee;
    clear: left;
    line-height: normal;
}
fieldset label{
        font-size: 13px;
    font-weight: bold;
    padding: 15px 20px 10px;
    margin-right: 10px;
    display: inline-block;
    color: #333;
}

fieldset.label_side > div {
    width: auto;
    margin-left: 140px;
    padding: 15px 20px;
    border-left: 1px solid #eee;
    clear: right;
      display: block;
}

.box-block fieldset input{    
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
}

input.text{
    width: 100% !important;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    border : solid #eee 1px;
    background-color: #fbfbfb;
    line-height: 32px;
   display: inline;
    height: 32px;
    padding: 0px 0 0 5px;

}

UPDATE UPDATE

I found that the problem is because of the input width 100%.. I am looking how to fix it. 我发现问题是因为输入宽度为100%..我正在寻找如何解决它。

IE6 and IE7 don't play nice when the display is set to "inline-block"; 当显示器设置为“内联块”时,IE6和IE7不能很好地播放;

Try adding the following to your label's CSS rule: 尝试将以下内容添加到标签的CSS规则中:

fieldset label{
    display:-moz-inline-stack;
    display:inline-block;
    zoom:1;
    *display:inline;
}

I would probably have a conditional sheet for IE browsers (usually how I deal with this problem). 我可能会有IE浏览器的条件表(通常我如何处理这个问题)。 Here's a site that exlains the problem in better details than I ever could: http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/ 这是一个以比以往更好的细节解决问题的网站: http ://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

May be you have to write vertical-align:top in your label & input . 可能你必须在你的标签输入中写下vertical-align:top Write like this: 像这样写:

label, input{
 vertical-align:top;
}

One solution that may work (it works for me) is to apply negative margin at input (textbox) ... or fixed width for ie7 or to drop ie7 support. 一个可行的解决方案(它适用于我)是在输入(文本框) ...或固定宽度为ie7或降低ie7支持时应用负边距

I had the same problem and i hated to have extra divs for border etc! 我有同样的问题,我讨厌为边境等额外的div!

So here is my solution which seems to work! 所以这是我的解决方案似乎工作!

You should use a ie7 only stylesheet to avoid the starhacks. 你应该使用ie7唯一的样式表来避免starhacks。

input.text{
    background-color: #fbfbfb;
    border : solid #eee 1px;
    width: 100%;
    -box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    height: 32px;

    *line-height:32px;
    *margin-left:-3px;
    *margin-right:-4px;
    display: inline;   
    padding: 0px 0 0 5px;

}

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

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