ie7中的内联div问题

时间:2013-07-30 23:22:18

标签: html css internet-explorer-7

我在JQuery中创建了一个简单的小部件,它将div中的texbox包装起来,添加了一个明文按钮和一个占位符。在http://jsfiddle.net/BpkDN/添加了主要位,CSS中的一些我找不到的东西在ie7中弄乱了样式。似乎适用于所有其他版本。

以下是我的小部件产生的摘录:

CSS:

 ::-ms-clear {
      display: none;
  }
.jui-textbox {
    border: 1px solid #DADADA;
    position: relative;
    padding:0 !important;
    white-space: nowrap;
    background: #fff;
    overflow: hidden;
    height: 33px;
    line-height: 33px;
    display: inline-block;
    *display:inline;
    margin: 10px 0;

}

.jui-textbox input {
    background-color: transparent;
    color: #313131;
    height: 33px !important;
    line-height:33px\9;
    width: 300px;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;  
    padding: 0;
    margin: 0 5px !important;
    border: none;
    float:left;
}

.jui-textbox-placeholder {
    position: absolute;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;  
    color: #A1A1A1;
    height: 33px;
    line-height: 33px;
    padding: 0;
    margin: 0;
    left: 5px;
    overflow: hidden;
    cursor: text;
}


.jui-textbox-hover {
    border: 1px solid #CACACA;
}
.jui-textbox-active {
    border: 1px solid #a1a1a1;
}

.jui-textbox-clear.show{
    display:inline-block !important;
    *display:inline !important; 
}
.jui-textbox-clear {
    display:none;
    cursor: pointer;
    background: #fff;
    border-left: 1px solid #a1a1a1;
    width: 33px;
    height: 33px;
    background-image:url(icons/x.png);
    background-position:center;
    background-repeat:no-repeat;    
}
.jui-hoverable:hover,.jui-hoverable-hovered
{   background-color: #f1f1f1;}

textarea:focus, input:focus{
    outline: none;
}

HTML

<div class="jui-textbox">
    <div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">                                                
           Default
    </div>
    <input type="text" style="width: 300px;">
    <div class="jui-textbox-clear jui-hoverable jui-icons-x"></div>
</div>

2 个答案:

答案 0 :(得分:1)

试试这个:

<强> CSS:

 ::-ms-clear {
      display: none;
  }
.jui-textbox {
    width: 300px;
    border: 1px solid #DADADA;
    position: relative;
    padding:0 !important;
    white-space: nowrap;
    background: #fff;
    overflow: hidden;
    height: 33px;
    line-height: 33px;
    display: inline-block;
    /**display:inline;*/
    margin: 10px 0;
}

.jui-textbox input {
    background-color: transparent;
    color: #313131;
    height: 33px !important;
    line-height:33px\9;
    width: 300px;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;  
    padding: 0;
    margin: 0 5px !important;
    border: none;
    float:left;
}

.jui-textbox-placeholder {
    position: absolute;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;  
    color: #A1A1A1;
    height: 33px;
    line-height: 33px;
    padding: 0;
    margin: 0;
    left: 5px;
    overflow: hidden;
    cursor: text;
}


.jui-textbox-hover {
    border: 1px solid #CACACA;
}
.jui-textbox-active {
    border: 1px solid #a1a1a1;
}

.jui-textbox-clear.show{
    display:inline-block !important;
    *display:inline !important; 
}
.jui-textbox-clear {
    display:none;
    cursor: pointer;
    background: #fff;
    border-left: 1px solid #a1a1a1;
    width: 33px;
    height: 33px;
    background-image:url(icons/x.png);
    background-position:center;
    background-repeat:no-repeat;
    position: absolute;
    right: 0;   
}
.jui-hoverable:hover,.jui-hoverable-hovered
{   background-color: #f1f1f1;}

textarea:focus, input:focus{
    outline: none;
}

<强> HTML:

<div class="jui-textbox">
        <div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">
                Default
        </div>
        <input type="text" style="width: 300px;">
        <div class="jui-textbox-clear jui-hoverable jui-icons-x"></div>
    </div>
    <br/>
<div class="jui-textbox">
        <div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">
                 Focused
        </div>
        <input type="text"  style="width: 266px;">
        <div class="jui-textbox-clear jui-hoverable jui-icons-x show"></div>
</div>

在IE7(Vista)中测试。

演示:http://jsfiddle.net/PENFT/

另一个解决方案,但它不是很干净:

  • width删除.jui-textbox

  • float:left;添加到".jui-textbox"并使用<br/> /&gt;更改<br style="clear:both"

注意: <br style="clear:both" />它太脏了。

答案 1 :(得分:0)

在这种情况下,JavaScript是简单的黑客,因为在IE7中:焦点不起作用。看看ie7-js project

  

IE7.js是一个JavaScript库   Microsoft Internet Explorer的行为   像符合标准的浏览器。它   修复了许多HTML和CSS问题   使透明的PNG正常工作   在IE5和IE6下。

升级MSIE5.5-7以与MSIE8兼容。

<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->

您也可以参考this SO questionIE7 doesn't support this pseudo class

相关问题