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 |
|
|
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:
<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>
- <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>