茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    純CSS實現(xiàn)設(shè)置半個字符的樣式
    來源:易賢網(wǎng) 閱讀:1830 次 日期:2014-07-04 20:46:22
    溫馨提示:易賢網(wǎng)小編為您整理了“純CSS實現(xiàn)設(shè)置半個字符的樣式”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了純CSS實現(xiàn)設(shè)置半個字符的樣式,分別實現(xiàn)了水平和垂直一半、水平和垂直三分之一等效果,需要的朋友可以參考下。

    在stackoverflow上看到的問題怎么給半個字符設(shè)置樣式,很多大神給出了答案。我就等就來學習圍觀吧。

    一:基本解決方案:

    html:

    代碼如下:

    <spanclass=”halfStyle”data-content=”X”>X</span>

    <spanclass=”halfStyle”data-content=”Y”>Y</span>

    <spanclass=”halfStyle”data-content=”Z”>Z</span>

    <spanclass=”halfStyle”data-content=”A”>A</span>

    css:

    代碼如下:

    .halfStyle{

    position:relative;

    display:inline-block;

    font-size:80px;/*oranyfontsizewillwork*/

    color:black;/*ortransparent,anycolor*/

    overflow:hidden;

    white-space:pre;/*topreservethespacesfromcollapsing*/

    }

    .halfStyle:before{

    display:block;

    z-index:1;

    position:absolute;

    top:0;

    left:0;

    width:50%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    color:#f00;

    }

    效果如圖:

    名單

    這種方法用于任何動態(tài)文本或單個字符,并且都是自動適用的。所有你需要做的就是在目標文本上添加一個class,剩下的就解決了。

    同時,保留了原文的可訪問性,可以被盲人或視障人士使用的屏幕閱讀器識別。

    單個字符的實現(xiàn):

    純CSS。所有你需要做的就是把.halfStyleclass用在每個你想要渲染一半樣式字符的元素上。

    對于每個包含字符的span元素,你可以添加一個data屬性,比如data-content=”X”,并且在偽元素上使用content:attr(data-content);這樣,.halfStyle:beforeclass將會是動態(tài)的,你不需要為每個實例進行硬編碼

    以下其它效果自行測試了。。。

    二:左右開弓,兩邊都設(shè)置樣式

    更改CSS:

    代碼如下:

    .halfStyle{

    position:relative;

    display:inline-block;

    font-size:80px;/*oranyfontsizewillwork*/

    color:transparent;/*hidethebasecharacter*/

    overflow:hidden;

    white-space:pre;/*topreservethespacesfromcollapsing*/

    }

    .halfStyle:before{/*createstheleftpart*/

    display:block;

    z-index:1;

    position:absolute;

    top:0;

    width:50%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#f00;/*fordemopurposes*/

    text-shadow:2px-2px0px#af0;/*fordemopurposes*/

    }

    .halfStyle:after{/*createstherightpart*/

    display:block;

    direction:rtl;/*veryimportant,willmakethewidthtostartfromright*/

    position:absolute;

    z-index:2;

    top:0;

    left:50%;

    width:50%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#000;/*fordemopurposes*/

    text-shadow:2px2px0px#0af;/*fordemopurposes*/

    }

    三:設(shè)置水平一半的樣式

    CSS:

    代碼如下:

    .halfStyle{

    position:relative;

    display:inline-block;

    font-size:80px;/*oranyfontsizewillwork*/

    color:transparent;/*hidethebasecharacter*/

    overflow:hidden;

    white-space:pre;/*topreservethespacesfromcollapsing*/

    }

    .halfStyle:before{/*createsthetoppart*/

    display:block;

    z-index:2;

    position:absolute;

    top:0;

    height:50%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#f00;/*fordemopurposes*/

    text-shadow:2px-2px0px#af0;/*fordemopurposes*/

    }

    .halfStyle:after{/*createsthebottompart*/

    display:block;

    position:absolute;

    z-index:1;

    top:0;

    height:100%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#000;/*fordemopurposes*/

    text-shadow:2px2px0px#0af;/*fordemopurposes*/

    }

    四:水平三分之一的樣式

    css:

    代碼如下:

    .halfStyle{/*basecharandalsothebottom1/3*/

    position:relative;

    display:inline-block;

    font-size:80px;/*oranyfontsizewillwork*/

    color:transparent;

    overflow:hidden;

    white-space:pre;/*topreservethespacesfromcollapsing*/

    color:#f0f;

    text-shadow:2px2px0px#0af;/*fordemopurposes*/

    }

    .halfStyle:before{/*createsthetop1/3*/

    display:block;

    z-index:2;

    position:absolute;

    top:0;

    height:33.33%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#f00;/*fordemopurposes*/

    text-shadow:2px-2px0px#fa0;/*fordemopurposes*/

    }

    .halfStyle:after{/*createsthemiddle1/3*/

    display:block;

    position:absolute;

    z-index:1;

    top:0;

    height:66.66%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#000;/*fordemopurposes*/

    text-shadow:2px2px0px#af0;/*fordemopurposes*/

    }

    五:垂直三分之的樣式

    css:

    代碼如下:

    .halfStyle{/*basecharandalsotheright1/3*/

    position:relative;

    display:inline-block;

    font-size:80px;/*oranyfontsizewillwork*/

    color:transparent;/*hidethebasecharacter*/

    overflow:hidden;

    white-space:pre;/*topreservethespacesfromcollapsing*/

    color:#f0f;/*fordemopurposes*/

    text-shadow:2px2px0px#0af;/*fordemopurposes*/

    }

    .halfStyle:before{/*createstheleft1/3*/

    display:block;

    z-index:2;

    position:absolute;

    top:0;

    width:33.33%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#f00;/*fordemopurposes*/

    text-shadow:2px-2px0px#af0;/*fordemopurposes*/

    }

    .halfStyle:after{/*createsthemiddle1/3*/

    display:block;

    z-index:1;

    position:absolute;

    top:0;

    width:66.66%;

    content:attr(data-content);/*dynamiccontentforthepseudoelement*/

    overflow:hidden;

    pointer-events:none;/*sothebasecharisselectablebymouse*/

    color:#000;/*fordemopurposes*/

    text-shadow:2px2px0px#af0;/*fordemopurposes*/

    }

    更多信息請查看IT技術(shù)專欄

    更多信息請查看網(wǎng)頁制作
    易賢網(wǎng)手機網(wǎng)站地址:純CSS實現(xiàn)設(shè)置半個字符的樣式
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)