Я хочу, чтобы фигура сердца была черной при щелчке, но изменение цвета .heart не повлияет на ее: до: после селектора. Есть ли способ сделать это?CSS: до: после фона цвет
.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;
}
Вопросы, ищущих код помощи должны включать короткий код, необходимый для его воспроизвести ** в самом вопросе ** желательно в [** Stack SNIPPET **] (https: // блог .stackoverflow.com/2014/09/введение-работоспособной-на JavaScript CSS-и-HTML-код-фрагменты /). См. [** Как создать минимальный, полный и проверенный пример **] (http://stackoverflow.com/help/mcve) –
Загрузите скрипт как с html, так и css, нам будет проще помочь тебе. – Omnitored
спасибо в следующий раз! –