2011-04-27 3 views
0

이 텍스트의 첫 번째 문자를 css $ 50.00으로 겹쳐서 $가 나머지 텍스트의 높이의 절반에 불과하도록하고 싶습니다.위 첨자 css가있는 텍스트의 첫 번째 항목

어떻게하면 CSS로 할 수 있습니까? 텍스트 조각에서 첫 번째 심볼을 선택하고 CSS로 위 첨자를 매길 수있는 방법이 있습니까?

답변

1
span.price:before{ content:'$'; font-size:xx-small; vertical-align:top; } 

이 만들 것입니다 :

<p>The current price is <span class="price">100.0</span></p> 

속으로 : 그 $ 제외

The current price is $100.0 

이 첨자 될 것입니다.

편집 : 다시 테스트하여 위의 작업을 확인할 수 있습니다. 그러나 모든 브라우저는 CSS에서 전후를 지원하지 않습니다.

그렇지 않으면 당신은 다음과 같이 HTML 함께 할 단지 수 : 개념 마크 업의

<p>The current price is <sup class="price">$</sup>100.0</p> 

증명을 두 솔루션 :

<!DOCTYPE html> 
<html dir="ltr" lang="en-US"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta charset="UTF-8"> 
    <title>Price test</title> 
    <style> 
     span.price:before{ content:'$'; font-size:xx-small; vertical-align:top; } 
    </style> 
</head> 
<body> 
    <p>The price is <span class="price">100.0</span></p> 
    <p>The price is <sup>$</sup>100.0</p> 
</body></html>