【问题标题】:How to override line-height and height css properties that are adding from external css using inline css?如何覆盖使用内联 css 从外部 css 添加的 line-height 和 height css 属性?
【发布时间】:2015-01-08 07:05:01
【问题描述】:

我有一个如下的文本字段:

<input name="course_code" id="course_code" placeholder="Course Code" type="text">

适用于上述文本字段的外部css如下:

height: 20px;
line-height: 20px;

我试图通过检查 textfield 元素从 firebug 控制台取消选中这些属性,它开始看起来很好。

所以我想通过使用一些可以覆盖上述两行的内联 css 代码或内部 css 代码来忽略这些字段。

我怎么能这样做?请帮帮我。

谢谢。

【问题讨论】:

    标签: css height textfield


    【解决方案1】:

    你可以试试initialinherit

    <input name="course_code" id="course_code" style="height:initial;line-height:inherit" placeholder="Course Code" type="text">
    

    您也可以使用unset,但仅在 Chrome 和 Firefox 中受支持:

    style="height:unset;line-height:unset"
    

    【讨论】:

      【解决方案2】:
      <input name="course_code" id="course_code" placeholder="Course Code" type="text" style="height:some      
      value !important;line-height:somevalue !important">
      

      !important 用于忽略所有 css 并应用最近的 css 并通过它。

      【讨论】:

      • 它是 CSS1 规范的一部分,并且一直存在,并且总是很容易实现,浏览器似乎在第一次尝试时就做到了。至少(根据个人经验)IE5.5+、Firefox 1+、Safari 3+、Chrome 1+。几乎所有支持 CSS 的浏览器都支持(这是您关心的每个浏览器)。 :D
      猜你喜欢
      • 2012-09-06
      • 1970-01-01
      • 2012-10-28
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多