Input border displays in Chrome but not in IE

2019-07-16 08:09发布

问题:

I'm creating a web form, and I've discovered a weird little bug or something: while the border and background styling that I add to my text input fields works in Chrome, I get nothing in IE8 or 9. As in, no borders or backgrounds. To look at it, you would not even know the input fields exist unless you either hit tab or manage to click in the right place, as the focus attribute works just fine.

I've seen several questions that have the reverse problem - border works in IE but not Chrome - but not for this one. I've tried border:default, I've tried really dark backgrounds, I've tried deleting the entire class in my css, and my input fields are still invisible in IE unless they are focused.

Here are parts of my CSS (left out definitely un-related sections):

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;
}

And here are (parts of) the related HTML (it's a pretty long form):

<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>

Thanks in advance!

回答1:

Looks like you're using inset, which depends on a border-color property. So break them out as border-color:color; and border-style:inset; instead of single tagging it like you would if it was just a solid, dashed, dotted etc. property. Worth giving a shot.



回答2:

It's being caused by the border:1px thin #99ccff; - for some reason (i have no idea why) IE interprets this as border-style:none.

If you remove the line, your borders magically show up again...

EDIT: i have an idea why, it's just invalid css - you specify 2 width's in this line, and IE tries to interpret thin as a border-style...



回答3:

Just changing border to border-width in the input[type='text'], input[type='tel'], input[type='email'] part of your CSS works for IE8. Check it out.



回答4:

Pretty sure li input[checkbox], input[text] is not what you intended. Try li input[type="checkbox"], li input[type="text"] instead

Also, be sure to use double quotes around type selectors.