【问题标题】:Input border displays in Chrome but not in IE输入边框在 Chrome 中显示,但在 IE 中不显示
【发布时间】:2012-02-04 09:13:28
【问题描述】:

我正在创建一个 Web 表单,但发现了一个奇怪的小错误或其他问题:虽然我添加到文本输入字段的边框和背景样式在 Chrome 中有效,但在 IE8 或 9 中却一无所获。在,没有边界或背景。查看它,您甚至不会知道输入字段存在,除非您点击选项卡或设法单击正确的位置,因为焦点属性工作正常。

我已经看到几个具有相反问题的问题 - 边框在 IE 中有效,但在 Chrome 中无效 - 但不适用于这个。我试过border:default,我试过非常暗的背景,我试过删除我的css中的整个类,我的输入字段在IE中仍然不可见,除非它们被聚焦。

这是我的 CSS 的一部分(绝对不相关的部分被省略了):

input[type='checkbox']
{
    width:1em;
    float:left;
    margin-left:1em;
    margin-right:0.5em;
    border:none;
}

.form
{

    font-size:12px;
    font-family:Georgia;
    width:25em;
    color:#000;
}

.form_large
{

    background:#fff;
    font-family:Georgia;
    font-size:12px;
    width:35em;
    border:2px inset #ccccff
}

.form_medium {  

    font-size:12px;
    font-family:Georgia;
    width:20em;
    color:#000;
    margin-left:0.5em;
    border:2px inset #ccccff;
}

.form_qty {

    font-size:12px;
    font-family:Georgia;
    width:3em;
    color:#000;
    margin-left:0.5em;
    border:2px inset #ccccff;
}

input[type='text'], input[type='tel'], input[type='email']
{

    color:#000033;
    background:#FFF;
    border:1px thin #99ccff;
}

input[type='checkbox']
{

    color:#cFF;
}

li input[checkbox], input[text]
{

    left:-2;
    margin-left:0;
    opacity:0;
    z-index:2;
    cursor:pointer;
    height:1em;
    width:1em;
    top:0;
    border:1px solid #000033;
}

这里是(部分)相关的 HTML(这是一个很长的形式):

<label for="input_1">Name/Company*</label>
  <input type="text" name='name' id="input_1" placeholder='Full name or Company name' required='required' class='form_medium'  />
</p>
<p>
  <label for="input_2">Address</label>
  <input type="text" name='Address' id="input_2" class='form_medium'  />
</p>
<p>
  <label for='input_3'>City*</label>
  <input type='text' id='input_3' name='City' required='required' class='form_medium'  />
</p>
<p>
  <label for='input_4'>Phone*</label>
  <input type='tel' pattern="\d{10}" name='phone' placeholder='e.g. 0123456789'id='input_4'class='form_medium' required='required'  />
</p>
    <p>
  <label for="input_5">E-mail</label>
  <input type="email" name='email' placeholder='e.g. jack@example.net'id="input_5" class='form_medium'  />
</p>
<p><p3>Please select all that apply:</p3></p>
<ol>
  <li class='main'>
    <input name='questions' type='checkbox' id='checkbox_1'label="label" for='checkbox_1'   />
    Questions:**
    <ol>
      <li class='sub_1'>
        <input name='Questions' type='text' class='form_large' cols="60" rows="5" placeholder='Do you have any questions about your equipment or our services?' id='input_6' />
      </li>
    </ol>
  </li>
</ol>
<ol>
  <li class='main'>
    <input name='Visit' type='checkbox' checked id='checkbox_2'label="label" for='checkbox_2'   />
    Visit (select type, all that apply):
    <ol>
      <li class='sub_1'>
        <input name='Service'  type='checkbox' id="checkbox_3"  label="label" for='checkbox_3' />
        Service
        <ol>
          <li class='sub_2'>
            <input name='Change Filters' type='checkbox'  id='checkbox_4' />
            Change filters
                <ol>
                    <li class='sub_3'>
                        <input name='Salt' type='checkbox'  id='salt_del'  />
            Deliver Salt
            <input type="text" name='del_salt' id='del_salt' class='form_qty'  />
          </li>
          </ol>
          </li>
          <li class='sub_2'>
            <input name='Repair' type='checkbox'  id='checkbox_5'  />
            Repair</li>
          <li class='sub_2'>
            <input name='Move' type='checkbox'  id='checkbox_6'  />
            Move Equipment</li>
          <li class='sub_2'>
            <input name='Hook_Up' type='checkbox'  id='checkbox_7'  />
            Hook up Equipment</li>
          <li class='sub_2'>
            <input name='Disconnect' type='checkbox'  id='checkbox_8'  />
            Disconnect Equipment</li>
        </ol>
      </li>
      <li class='sub_1'>
        <input name='Delivery'  type='checkbox' id="checkbox_9"  label="label" for='checkbox_9'/>
        Delivery (specify quantity)
        <ol>
          <li class='sub_2'>
            <input name='Water' type='checkbox' id='checkbox_10'  />
            Water (5-gal bottled)
            <input type="text" name='del_wat' id='del_wat' class='form_qty'  />
          </li>
          <li class='sub_2'>
            <input name='Salt' type='checkbox'  id='checkbox_11'  />
            <label class='qty' for='del_salt'>Salt</label>
            <input type="text" name='del_salt' id='del_salt' class='form_qty'  />
            <ol>
                    <li class='sub_3'>
                        <input name='Salt' type='checkbox'  id='filt_change'  />
            Change Filters
            </li>
          </ol>
          </li>
          <li class='sub_2'>
            <input name='Filt_deliver' type='checkbox'  id='checkbox_12'  />
            <label class='qty' for='del_filt'>Filters</label>
            <input type="text" name='del_filt' id='del_filt' class='form_qty'  />
          </li>
          <li class='sub_2'>
            <input name='Parts' type='checkbox'  id='checkbox_13'  />
            <label class='qty' for='del_parts'>Parts</label>
            <input type="text" name='del_parts' id='del_parts' class='form_qty'  />
          </li>
          <li class='sub_2'>
            <input name='Other_deliver' type='checkbox'  id='checkbox_14'  />
            Other (please specify)**
            <input type="text" name='del_other' id='del_other' class='form_medium'  />
          </li>
        </ol>
      </li>
      <li class='sub_1'>
        <input name='Other_visit'  type='checkbox' id="checkbox_15"  label="label" for='checkbox_15'/>
        Other Visit (please specify)**
        <input type="text" name='visit_other' id='visit_other' class='form_medium' />
      </li>
    </ol>
  </li>
</ol>
<ol>

提前致谢!

【问题讨论】:

  • 您能否创建一个示例来重现此问题,并且不需要通读代码墙? sscce.org

标签: html css internet-explorer google-chrome


【解决方案1】:

看起来您正在使用 inset,这取决于边框颜色属性。所以将它们分解为边框颜色:颜色;和边框样式:插图;如果它只是一个实心、虚线、虚线等属性,而不是像你那样单独标记它。值得一试。

【讨论】:

    【解决方案2】:

    这是由 border:1px thin #99ccff; 引起的 - 出于某种原因(我不知道为什么)IE 将其解释为 border-style:none

    如果你删除这条线,你的边框会神奇地再次出现......

    编辑:我知道为什么,它只是无效的 css - 你在这一行中指定了 2 个宽度,IE 尝试将 thin 解释为边框样式......

    【讨论】:

    • 好点,验证器可能会揭示更多问题,而不仅仅是一些跨浏​​览器兼容性的小边框问题
    【解决方案3】:

    只需将 CSS 的 input[type='text'], input[type='tel'], input[type='email'] 部分中的 border 更改为 border-width 即可适用于 IE8。检查它out

    【讨论】:

    • 我相信你是对的。不过,它似乎确实解决了 IE 中的问题。
    【解决方案4】:

    很确定li input[checkbox], input[text] 不是您想要的。 改用li input[type="checkbox"], li input[type="text"]

    另外,请务必在类型选择器周围使用双引号。

    【讨论】:

      猜你喜欢
      • 2018-03-07
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 2012-09-16
      • 2017-09-21
      • 2011-09-21
      • 1970-01-01
      相关资源
      最近更新 更多