html - 如何重置输入元素样式

标签 html css

我有一个表格,其中有:

<input type="file" size="6" />

不幸的是,该按钮将显示在输入栏中! 这是因为我已经为表单中的所有输入设置了一个 css:

#msform input, #msform textarea {

    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 2px;
    margin-bottom: 10px;
    width: 80%;
    height: 29px;


    box-sizing: border-box;
    font-family: montserrat;
    color: #2C3E50;

    font-size: 12px;
}

请看:http://jsfiddle.net/kg48vpfq/ 我怎样才能只清除这个输入元素的 css,或者我怎样才能更好地获得按钮旁边的输入框。

谢谢

最佳答案

height: auto 添加到 file input。在 inputtextarea 的通用样式之后添加它。

#fieldset2 input[type="file"] {
    height: auto;
    border: 0;
}

Demo

#msform fieldset:not(:first-of-type) {
  display: none;
}
#msform label {
  width: 20%;
  float: left;
  margin-top: 10px;
}
/*inputs*/

#msform input,
#msform textarea {
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 2px;
  margin-bottom: 10px;
  width: 80%;
  height: 29px;
  box-sizing: border-box;
  font-family: montserrat;
  color: #2C3E50;
  font-size: 12px;
}
#msform textarea {
  min-height: 100px;
  margin-left: 50px;
}
#fieldset2 input[type="file"] {
  height: auto;
  border: 0;
}
<form id="msform">
  <fieldset id="fieldset2">
    <input type="file" size="6" />
  </fieldset>
</form>

关于html - 如何重置输入元素样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32088212/

相关文章:

css - ngDialog 深色覆盖覆盖对话框

python - Django 不加载内部 .css 文件

javascript - jQuery 不适用于添加的行

html - 嵌套层次结构 CSS 问题

html - Safari 下部的选择框无法选择

javascript - 分页和排序表的问题

使用显示 block 和 100% 宽度属性时 HTML 表格 td 不是全宽

php - 改变列宽 Yii

html - CSS-clearfix : Why using "table" for the "display"-property?

html - 对齐 3 列,中间列 HR 可调