background-image css clickable. Has as?

2

How to make a background-image css clickable?

Here is the code I have:

position: relative;
width:140px;
font-family: Arial, Verdana; 
font-size: 15px; 
padding: 5px; 
background-image:url(../../img/buscar-icon.png);
background-repeat:no-repeat;
background-position:right;
    
asked by anonymous 10.12.2015 / 16:22

1 answer

3

Maybe you're talking about adding this to css:

cursor:pointer

If you need to add an action only when the click is executed, then use :active

.element:active{}

Example:

.clicavel{
   height: 150px;
   width: 150px;
   background-color: lime;
   cursor: pointer;
   transition: background-color 400ms ease;
   justify-content: center;
   align-items: center;
   display: flex;
   text-align: center;
}

.clicavel:active{
     background-color: steelblue;
}
<div class="clicavel">
   Clique e segure
</div>
    
10.12.2015 / 16:31