簡體   English   中英

簡化樣式表中的html css選擇器

[英]simplify html css selectors in style sheet

我有一些帶有引導類的以下html

<input id="OP_CG1" class="form-control input-sm text-right" value="160"  type="text">
<input id="OP_CG2" class="form-control input-sm text-right" value="280"  type="text">
<input id="OP_CG3" class="form-control input-sm text-right" value="600"  type="text">

我想簡化為

<input id="OP_CG1" value="160"  type="text">
<input id="OP_CG2" value="280"  type="text">
<input id="OP_CG3" value="600"  type="text">

通過使用CSS選擇器。 我嘗試了這個,但是沒有用。

input[id^="OP_CG"].form-control.input-sm.text-right
{
}

你能幫助我嗎。 我想要一個不使用Jquery的解決方案

為此,您必須將與應用於輸入的三個獨立CSS類相關聯的CSS合並為一條規則...

.form-control {
    /* form-control styles here */
}

.input-sm {
    /* input-sm styles here */
}

.text-right {
    /* text-right styles here */
}

會成為...

input[id^="OP_CG"] {
    /* form-control styles here */
    /* input-sm styles here */
    /* text-right styles here */
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM