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

CSS 偽元素應用元素的第一個字符

CSS pseudo-element to apply the first character of an element(CSS 偽元素應用元素的第一個字符)
本文介紹了CSS 偽元素應用元素的第一個字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的 h1 標簽中有以下內容:(Hello World)",所以我將以下內容添加到我的 css 以更改此元素的第一個字符:

I have the following content in my h1 tag: "(Hello World)" so I add the following to my css to change the first character of this element:

h1:first-letter { font-size:63px; color:#510007; font-family:Helvetica; }

但是,正如我所注意到的,第一個字母僅用于字母,那么是否有任何解決方法可以將此樣式應用于第一個字符?在這種情況下是(".

But, as I noticed, first-letter is only for letters, so is there any workarounds to apply this style to the first char? Which in this case is "(".

推薦答案

來自 規格:

標點符號(即 Unicode 中定義的字符 [UNICODE] 在open"(Ps)、close"(Pe)、initial"(Pi)、final"(Pf)和other"(Po)標點類)中,在第一個字母之前或之后應該是包括

Punctuation (i.e, characters defined in Unicode [UNICODE] in the "open" (Ps), "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that precedes or follows the first letter should be included

所以你的括號字母H被:first-letter選中,因為(被認為是標點符號,而不是字母.

So your bracket and the letter H are selected by :first-letter, because ( is considered a punctuation symbol, not a letter.

有兩種解決方法:

  1. 將左括號括在 span 標記中:

<!-- To style both (), wrap both in <span> tags -->
<h1><span>(</span>Hello World)</h1>

和目標h1 span:

h1 span {
    font-size: 63px;
    color: #510007;
    font-family: Helvetica;
}

  • 從文本中刪除括號:

  • Drop the brackets from your text:

    <h1>Hello World</h1>
    

    并使用 :before 和/或 :after 代替(IE7 和更早版本不支持):

    and use :before and/or :after instead (not supported in IE7 and older):

    /* To style both (), use h1:before, h1:after */
    h1:before {
        font-size: 63px;
        color: #510007;
        font-family: Helvetica;
    }
    
    h1:before { content: '('; }
    h1:after { content: ')'; }
    

  • 這篇關于CSS 偽元素應用元素的第一個字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

    相關文檔推薦

    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().方法返回的結果是否有序?)
    Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
    nth-Child CSS selectors(nth-子 CSS 選擇器)
    Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
    主站蜘蛛池模板: 色伊人网 | 老司机精品福利视频 | 蜜桃精品一区二区 | 精品国产99久久久久久宅男i | 欧美日韩在线一区二区 | 毛片网站在线播放 | 日本色婷婷 | 国产视频网 | 久久久久精| 欧美性猛交一区二区三区精品 | 刘玥大战28公分黑人 | 日韩毛片| 亚洲一区二区欧美 | 欧美日韩免费在线 | 毛片网站视频 | 天天爱天天色 | 91观看 | 亚洲久草 | 色网站在线观看 | 国产呦小j女精品视频 | 日韩和的一区二区 | 精久久久久 | 亚洲小视频 | 久久精品日韩 | 电家庭影院午夜 | 亚洲一区二区三区 | 午夜视频网站 | 国产一级片免费 | 免费网站观看www在线观 | 免费在线观看黄色片 | 日韩中文字幕一区 | 日本一级大毛片a一 | 黄色在线免费网站 | 久久国产精品视频 | 欧美三级欧美一级 | 日韩精品福利 | 91成人精品一区在线播放 | 午夜无遮挡 | 好色综合| 羞羞网站入口 | 激情影院在线观看 |