css控制文字前的小表徵圖

來源:互聯網
上載者:User
有些清單項目需要在文字前加個小表徵圖,如:

實現方法有多種,這裡使用<span>元素。

span標記是行元素,沒有寬高,雖然可以通過display:block;來改變。但是就會造成換行。

貼代碼:

[html]   www.php.cn<span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項1</span>  <span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項2</span>  <span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項3</span>  <span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項4</span>   <span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項1</span><span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項2</span><span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項3</span><span style="padding-left:19px;background:url(a.jpg) no-repeat;">選項4</span>

這裡使用了padding-left來共同實現這個小表徵圖的出現,就是讓文字靠右點

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.