クリック時にハートシェイプを黒にしたいが、心の色を変更してもbefore:afterセレクタには影響しない。そうする方法はありますか?CSS:before:背景色の後
.heart {
background-color: red;
height: 60px; /*dimension of the square*/
position: relative;
top: 40px; /*position from top*/
transform: rotate(-45deg); /*negative = counter clockwise, put 0 to try*/
width: 60px; /*dimension of the square*/
transition: all 1s ease; /*length of animation*/
}
.heart:before,
.heart:after {
content:""; /*kosong, for it to exist*/
background-color: red;
border-radius: 50%; /*perfect round curve*/
height: 60px; /*dimension of the shape*/
position: absolute;
width: 60px; /*dimension of the shape*/
}
.heart:before {
top: -30px; /*position of the left shape*/
left: 0; /*remember rotated ACW 45deg*/
}
.heart:after {
left: 30px; /*position of the right shape*/
top: 0px; /*remember rotated ACW 45deg*/
}
.heart
{
opacity:0.3; /*original state*/
}
.heart:hover
{
opacity:1; /*hover state*/
}
.heart:active
{
opacity:1; /*hover state*/
background:black;
}
コード助けを求める質問は、質問自体に**それを再現するために必要な最短のコードを含める必要があります**好ましくは[**スタックスニペット**](HTTPSで://ブログ.stackoverflow.com/2014/09/introduction-runnable-javascript-css-and-html-code-snippets /)。 [**最小限で完全で検証可能なサンプルを作成する方法**](http://stackoverflow.com/help/mcve) –
HTMLとCSSの両方でフィーリングをアップロードしてください。助けます。 – Omnitored
次回は感謝します! –