2016-03-02 48 views
0

我目前正在尝试制作三个输入框,它们的宽度相同,并且彼此齐平。输入是三种不同的类型,textareainput & select。我在Google Chrome中成功,但它在Firefox中完全无用。我已经通过堆栈溢出和互联网搜索,并没有找到一个很好的解释。<input>在Chrome浏览器中相互齐平,但不在FireFox中

这是我的HTML ...

<div id='add-topic-wrap'> 
    <h3 id='topic-wrap-title'>Add a new Topic</h3> 
    <div class='topic-input-wrap'> 
     <label>Topic: </label> 
     <input id='topic-input' type='text' ng-model='dashControl.topic.title' maxlength='30'></input> 
    </div> 
    <div class='topic-input-wrap'> 
     <label>Description: </label> 
     <textarea id='desc-input' ng-model='dashControl.topic.desc'></textarea> 
    </div> 
    <div class='topic-input-wrap'> 
     <label>Category: </label> 
     <select id='category-input' ng-model='dashControl.topic.category'> 
      <option>HTML5</option> 
      <option>CSS3</option> 
      <option>Javascript</option> 
      <option>PostgreSQL</option> 
      <option>Django</option> 
     </select><br> 
    </div> 
    <button id='submit-topic' ng-click='dashControl.addTopic(dashControl.logged_in_user)'>Submit</button> 
</div> 

这里是我的CSS ...

#add-topic-wrap{ 
    border: solid black .1em; 
    width: 95%; 
    margin: 1em auto 0 auto; 
} 

#topic-wrap-title{ 
    font-family: 'Raleway'; 
    text-align: center; 
    margin: 0.5em 0; 
} 

.topic-input-wrap{ 
    height: 3em; 
    margin-left: .5em; 
} 

.topic-input-wrap{ 
    font-family: 'Raleway'; 
    height: 3em; 
} 

#topic-input, #desc-input, #category-input{ 
    float: right; 
    margin-right: .5em; 
} 

#desc-input{ 
    width: 12.5em; 
} 

#category-input{ 
    width: 13em; 
    height: 1.6em; 
} 

#submit-topic{ 
    margin: 0 0 1em 6.5em; 
    height: 1.5em; 
    font-size: 1em; 
    font-family: 'Raleway'; 
    background-color: transparent; 
    border: black solid .1em; 
} 

左侧&火狐谷歌浏览器的截图右...

enter image description here

回答

1

的原因是您正在使用EM的,这是在某些浏览器有点无情。 如果您不支持ie8,请尝试rems。如果是,请使用%或px。

还可以使用:

box-sizing: border-box; 

,以确保它们完全一致。

快速小提琴: https://jsfiddle.net/eq54Lm5d/1/

而且您正在使用的ID的造型,你真的应该带班造型为更好的特异性行为。

+0

为什么我不使用ID?我所做的更改是针对单个标签的?他们是不是失去了什么? –

+0

可以使用它们,但它们比类具有更高的特异性,所以如果你使用类,你可以用id轻松覆盖它们,如果你需要的话:)尽管它不会影响你太多。 – anthonyroberts

相关问题