-- Simple HTML Solution --
Final result of easy to resize icon:
![two close X buttons with different thickness.]()
JSfiddle demo: https://jsfiddle.net/allenski/yr5gk3cm/
The simple HTML:
<a href="#" class="close" tabindex="0" role="button">close</a>
Note:
tabindex attribute is there to help accessibility focus of iOS touch devices.
role attribute is to let screen readers users know this is a button.
- The word
close is also intended for screen readers to mention.
The CSS code:
.close {
position: absolute;
top: 0;
right: 0;
display: block;
width: 50px;
height: 50px;
font-size: 0;
}
.close:before,
.close:after {
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 20px;
background-color: #F0F0F0;
transform: rotate(45deg) translate(-50%, -50%);
transform-origin: top left;
content: '';
}
.close:after {
transform: rotate(-45deg) translate(-50%, -50%);
}
To adjust thickness of close X icon, change the width property. Example for thinner icon:
.close:before,
.close:after {
width: 2px;
}
To adjust length of close X icon, change the height property. Example:
.close:before,
.close:after {
height: 33px;
}