如何使用内联 css 覆盖从外部 css 添加的行高和高度 css 属性



我有一个文本字段如下:

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

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

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

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

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

我该怎么做?请帮助我。

谢谢。

你可以

尝试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"
<input name="course_code" id="course_code" placeholder="Course Code" type="text" style="height:some      
value !important;line-height:somevalue !important">

!important用于忽略所有CSS,并在它传递时应用最近的CSS。

最新更新