久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 CSS 僅將 HTML 選項元素的第一個字母大寫

How to capitalize ONLY the first letter of an HTML option element using CSS?(如何使用 CSS 僅將 HTML 選項元素的第一個字母大寫?)
本文介紹了如何使用 CSS 僅將 HTML 選項元素的第一個字母大寫?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

text-transform: capitalize 在這種情況下不起作用,因為文本已經(jīng)是大寫了.

text-transform: capitalize does not work in this case because the text is already uppercase.

<select>
    <option>
      OPTION
    </option>
</select>

這也不起作用.

select{
  -webkit-appearance: none;
  text-transform: lowercase;
  display: inline;
}

select option::first-letter{
  text-transform: uppercase;
}

它應(yīng)該(至少)使用 CSS(而不是 JS)在 Chrome 上工作.

It should work on Chrome (at least) using CSS (and not JS).

推薦答案

在 Chrome 和 Firefox 中,您可以為 option 元素設(shè)置樣式 if 它的 select 的大小大于 1.

In Chrome and Firefox, you can style an option element if its select has a size greater than 1.

您可以通過以下方式利用它:

You can exploit this as follows:

select {
  height: 1.4em;             /* show only one option when not focused */
}

select:focus {
  height: 100%;              /* show all options when focused */
}

option  {
  text-transform: lowercase; /* change to lowercase */
  padding-right: 2em;        /* the select's width is based on width of its longest non-transformed ... */
                             /* option.  padding ensures that option is completely visible */
  display: none;             /* hide all options by default (see below) */
}

option::first-letter {
  text-transform: uppercase; /* change first letter to uppercase */
}

option:checked, select:focus option { 
  display: block;            /* show selected option, or show all options when the select is focused */
}

<select size="4">
  <option selected>NOW IS THE TIME</option>
  <option>for all good men</option>
  <option>tO Come To tHe aid</option>
  <option>of the party</option>
</select>

它不會相當(dāng)像普通的選擇框一樣工作,Chrome 有一個奇怪的行為,即所選選項的背景是灰色的.不知道如何防止這種情況發(fā)生.

It won't quite act like a normal select box, and Chrome has a strange behavior in that the selected option will have a gray background. Can't figure out how to prevent that.

這篇關(guān)于如何使用 CSS 僅將 HTML 選項元素的第一個字母大寫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結(jié)果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當(dāng)使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標(biāo)簽使用相同的 ID?)
主站蜘蛛池模板: 在线观看视频国产 | 97视频在线观看免费 | 国产小视频在线播放 | 久久精品99久久久久久 | 久久精品久久久 | 亚洲精品www久久久久久广东 | 日本黄色三级视频 | 操操操操操操 | 玖玖在线视频 | 亚洲成人av在线 | 成年人免费在线观看 | 日韩成人在线观看视频 | 神马午夜嘿嘿 | 在线中文字幕av | 欧美一区二 | 欧美精品99久久久 | 欧美三级韩国三级日本三斤在线观看 | 日韩五十路 | 日本一级淫片色费放 | 亚洲天堂中文字幕 | 亚洲免费黄色 | 黄色成人毛片 | www.欧美精品 | 久久99精品久久久久久琪琪 | 久草资源在线 | 97国产在线观看 | 草草视频在线 | 中文字幕三区 | 日韩免费毛片 | 日皮视频免费看 | 中文字幕在线免费视频 | 国产成人区 | 国产精品久久久久久无人区 | 国产日韩欧美在线 | 真人毛片免费看 | 欧美资源在线 | 国产一区二区三区免费 | 国产草草 | a毛片大片 | 国产欧美久久久 | 欧美又大粗又爽又黄大片视频 |