Vertically align an asterisk on a line

What?
So I have an unordered list of values (*, 1, 2, 3...) and for styling reasons I want the asterisk to be the same size as the numbers but not overlap any list item beneath it. By increasing the size of the asterisk, this often increases the line-height and causes the overall line height to change for other objects in the same row. The problem afterwards was that the asterisk character would overlap the item beneath it (in this case #2) so when a user clicked on #2 they would in fact be clicking on the item containing the asterisk above it.

Objective
Box List Before:Box List After
  • *
  • 1
  • 2
  • 3
  • *
  • 1
  • 2
  • 3

How?
Decrease the line-height of the asterisk and vertically align to the bottom ( line-height: 10px; vertical-align: bottom;). Here's the whole code:
copyraw
<style>
ul.listafter{
        list-style-type:none;
        width:130px;
        height:130px;
        background:none;
}
ul.listafter li{
        width:59px;
        height:52px;
        margin:0;
        padding:0;

        color: #000;
        background-color:red;
        border:1px solid #000;

        cursor:pointer;
        float:left;
        vertical-align:bottom;

        font-size:40px;
        font-weight:700;
        line-height:50px;
        text-align:center;
}
ul.listafter li:hover{
        color: #fff;
        background-color:#000;
}
ul.listafter span.asterisk{
        font-size:70pt;
        line-height:10px;
        vertical-align:bottom;
        margin:2px 0 0 5px;
}
</style>
<ul class="listafter">
        <li><span class="asterisk">*</span></li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
</ul>
  1.  <style> 
  2.  ul.listafter{ 
  3.          list-style-type:none; 
  4.          width:130px
  5.          height:130px
  6.          background:none; 
  7.  } 
  8.  ul.listafter li{ 
  9.          width:59px
  10.          height:52px
  11.          margin:0
  12.          padding:0
  13.   
  14.          color: #000; 
  15.          background-color:red; 
  16.          border:1px solid #000; 
  17.   
  18.          cursor:pointer; 
  19.          float:left; 
  20.          vertical-align:bottom; 
  21.   
  22.          font-size:40px
  23.          font-weight:700
  24.          line-height:50px
  25.          text-align:center; 
  26.  } 
  27.  ul.listafter li:hover{ 
  28.          color: #fff; 
  29.          background-color:#000; 
  30.  } 
  31.  ul.listafter span.asterisk{ 
  32.          font-size:70pt
  33.          line-height:10px
  34.          vertical-align:bottom; 
  35.          margin:2px 0 0 5px
  36.  } 
  37.  </style> 
  38.  <ul class="listafter"> 
  39.          <li><span class="asterisk">*</span></li> 
  40.          <li>1</li> 
  41.          <li>2</li> 
  42.          <li>3</li> 
  43.  </ul> 



Category: Cascading Stylesheets :: Article: 434

Please publish modules in offcanvas position.