Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement the button css like Spotify play button in the table row

Hi I tried to custom my button like Spotify.

When hover the table row show play button and click the play button change image.

enter image description here

I consulted from other fiddle and updated. Now I click one element and the other one will hide. However, I don't know how to hide one of them in the beginning.

a {
  display: block;
  font-size: 18px;
  border: 2px solid gray;
  border-radius: 100px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
}
a:hover {
  font-size: 18px;
  border: 2px solid green;
  border-radius: 100px;
  width: 100px;
  height: 100px;
}
a:target {
  display: none;
  font-size: 18px;
  border: 2px solid red;
  border-radius: 100px;
  width: 100px;
  height: 100px;
}
<a id="btn" href="#btn">Play</a>
<a id="btn2" href="#btn2">Pause</a>
like image 504
Raymond Yeh Avatar asked Nov 24 '25 21:11

Raymond Yeh


1 Answers

You can do following way using pure css without scripting.

a {
  display: block;
  font-size: 18px;
  border: 2px solid gray;
  border-radius: 100px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
}
a:hover {
  font-size: 18px;
  border: 2px solid green;
  border-radius: 100px;
  width: 100px;
  height: 100px;
}
a:target {
  display: none;
  font-size: 18px;
  border: 2px solid red;
  border-radius: 100px;
  width: 100px;
  height: 100px;
}
a:nth-last-child(2){
  display:none;
  }
a:first-child:target + a:nth-last-child(2){
  display:block;
  }
<a id="btn" href="#btn">Play</a>
<a id="btn2" href="#btn2">Pause</a>
like image 63
ketan Avatar answered Nov 26 '25 11:11

ketan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!