很简单的哇,把 “亿元” 两个字使用绝对定位挂在数字后面就行了,或者数字设置一个负的 margin-right以下是示例代码:<!-- 使用绝对定位 --> <body> <div class="demo"> <div class="title">测试</div> <div class="number"> 216.11 <span class="unit">亿元</span> </div> </div> </body> <style> .demo { line-height: 35px; text-align: center; color: #303030; } .demo .title { font-size: 13px; } .demo .number { font-size: 20px; font-weight: bold; position: relative; } .demo .number .unit { font-size: 12px; font-weight: normal; position: absolute; } </style><!-- 使用 margin-right: -36px --> <body> <div class="demo"> <div class="title">测试</div> <div class="number"> 216.11 <span class="unit">亿元</span> </div> </div> </body> <style> .demo { line-height: 35px; text-align: center; color: #303030; } .demo .title { font-size: 13px; } .demo .number { font-size: 20px; font-weight: bold; margin-right: -35px; /* "亿元"两个字的宽度 */ } .demo .number .unit { font-size: 12px; font-weight: normal; } </style>
很简单的哇,把 “亿元” 两个字使用绝对定位挂在数字后面就行了,或者数字设置一个负的
margin-right
以下是示例代码:
