Right I have some css code I use to make my buttons. I am using pseudo elements to create my button icons, and I load my buttons from a sprite sheet. In my example I have 3 buttons, but sometimes I have more.
If you study my css you can see that the only thing changing between each pseudo element is sprite position. So a lot of code is being repeated.
Is there anyway I can use less code, but do the same thing?
.add_button,
.excel_button,
.history_button {
color: #000;
padding-right: 10px;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 2px;
border-radius: 5px;
border: 2px solid #009900;
height: 25px;
width: 165px;
margin-bottom: 5px;
cursor: pointer;
font-weight: 500;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: relative;
}
.add_button::before {
content: "";
width: 25px;
height: 25px;
background: url("../../images/buttons/buttons_25x25.png") 0px 0px no-repeat;
float: left;
margin: -1px 10px 0px 0;
}
.excel_button::before {
content: "";
width: 25px;
height: 25px;
background: url("../../images/buttons/buttons_25x25.png") -99px -50px no-repeat;
float: left;
margin: -1px 10px 0px 0;
}
.history_button::before {
content: "";
width: 25px;
height: 25px;
background: url("../../images/buttons/buttons_25x25.png") -125px 0px no-repeat;
float: left;
margin: -1px 10px 0px 0;
}