Target certain words with CSS?

前端 未结 3 1893

This is kind of a theory question but I wonder whether it is possible or not.

So if you have a div with some content like...

£100.00 - BUY<
相关标签:
3条回答
  • 2021-01-21 04:24

    You could target it by wrapping it in a span element:

    jsFiddle example

    <div><span class="price">$100.00</span> - BUY</div
    
    0 讨论(0)
  • 2021-01-21 04:31

    No, that can't be done without wrapping the desired text in another element, typically a <span>.

    0 讨论(0)
  • 2021-01-21 04:37

    You can use this

    <div><span id="price">£100.00</span> - BUY</div>

    CSS

    #price {  
     font-size: 2em; // double of the current font  
    }  
    
    div {  
    font-size: inherit; // get the font-size from the browser or the document.  
    }
    

    This will give the div a default font-size but the span with id price will have twice the font-size as the div.

    0 讨论(0)
提交回复
热议问题