简体   繁体   English

Html css IE7 内联块

[英]Html css IE7 inline-block

I have a problem with a simple form, in IE7.我在 IE7 中遇到一个简单表单的问题。

In FF, and other browsers, I have no problem.在 FF 和其他浏览器中,我没有问题。

<form class="hotline_form">
     <fieldset>
         <legend>TEST</legend>
         <div class="field">
             <label class="question">Name:</label><input name="name"  type="text">
         </div>
         <div class="field">
             <label class="question">Username:</label><input name="name"  type="text">
         </div>
     </fieldset>
</form>

My CSS styling:我的 CSS 造型:

form.hotline_form{
    margin:0; padding: 0;
}
form.hotline_form fieldset{
    border: 0;
    padding: 0;
    margin: 25px 0 0 0;
}
form.hotline_form fieldset legend{
    width: 100%;
    padding: 0px 0px 5px 0px;
    margin: 5px 0px 5px 0px;
    border-bottom: 1px solid #999;
}
form.hotline_form fieldset div.field label{
    display: inline-block; 
    width: 130px; 
    padding: 0pt 20px 0pt 0pt;
    margin-top:5px;
    vertical-align: top;
    zoom:1; *display: inline; _height: 15px; /* IE7 fix*/
}
form.hotline_form fieldset div.field input, form.hotline_form fieldset div.field select, form.hotline_form fieldset div.field textarea{
    width: 330px;
    margin: 5px 0px 0px 0px;
    padding: 1px 0px 1px 0px;
}
form.hotline_form div.submit{
margin: 40px 0 0;
padding: 0 0 5px;
width: 100%;
}
form.hotline_form div.submit input{
    float: right;
    padding: 0px 7px 0px 0px;
}

Notice the fix I have tried注意我尝试过的修复

zoom:1; *display: inline; _height: 15px; /* IE7 fix*/

I got that from http://flipc.blogspot.com/2009/02/damn-ie7-and-inline-block.html我从http://flipc.blogspot.com/2009/02/damn-ie7-and-inline-block.html 得到

In Firefox it display, like this:在 Firefox 中显示如下:

在此处输入图像描述

And IE7:和 IE7:

在此处输入图像描述

I usually load different.CSS files for Inte.net Explorer, it keep my code clean:我通常为 Inte.net Explorer 加载不同的 .CSS 文件,它使我的代码保持干净:

<!--[if IE 7]> <link href="ie7.css" rel="stylesheet" type="text/css"> <![endif]-->
<!--[if IE 8]> <link href="ie8.css" rel="stylesheet" type="text/css"> <![endif]-->

Could this be a case of IE's funky way of dealing with padding?这可能是 IE 处理填充的时髦方式的一个例子吗? Is your fieldset fit tightly around those text boxes?您的字段集是否紧紧围绕这些文本框?

http://en.wikipedia.org/wiki/Inte.net_Explorer_box_model_bughttp://en.wikipedia.org/wiki/Inte.net_Explorer_box_model_bug

See this alot in IE, its an issue with how IE formats what the code tells it to do在 IE 中经常看到这个问题,这是 IE 如何格式化代码告诉它要做的事情的问题

Your best bet is use to use JS to identify what browser is being run then build a custom style sheet for IE.您最好的选择是使用 JS 来识别正在运行的浏览器,然后为 IE 构建自定义样式表。 Here are some links to help out这里有一些链接可以提供帮助

http://javascript.about.com/library/blbrsdet.htm http://javascript.about.com/library/blbrsdet.htm

http://www.w3schools.com/js/js_browser.asp http://www.w3schools.com/js/js_browser.asp

Best of luck to you:)祝你好运:)

I would give the div.field overflow:hidden and then float:left;我会给 div.field overflow:hidden 然后 float:left; both the label and input, make sure when using margins for float elements you give them a display:inline; label 和输入,请确保在为浮动元素使用边距时为它们提供 display:inline;

No hack required and works for all browsers, you can set a height and line-height for both the label and input.无需破解,适用于所有浏览器,您可以为 label 和输入设置高度和行高。

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

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