1

I have created an abstract type button (was meant to be a cloud originally, but has become something different!)

But now I am unable to change the hover color of all the elements in the button - can somebody see what I am doing wrong in that part?

Here is the code I am using for the button which I have hacked together from various tutorials I am watched on this.

.btn {
  position: relative;
  width: 150px;
  height: 50px;
  border-radius: 50%;
  background-color: #66b65d;
  transition: background-color 100ms linear, height 70ms ease-in, width 70ms ease-in;
  cursor: pointer;
  z-index: 999 !important;
}

.btn:before {
  content: "";
  display: block;
  width: 130px;
  height: 30px;
  position: absolute;
  top: 89;
  border-radius: inherit;
  background-color: #5ca754;
  ;
  z-index: -1 !important;
}

.btn:after {
  content: "";
  display: block;
  width: 130px;
  height: 30px;
  position: absolute;
  top: 89;
  border-radius: inherit;
  background-color: #508f49;
}

.btn:before {
  left: -10%;
  margin-left : calc( ( #{75)   );

}

.btn:after {
  right: 100%;
  margin-right : calc( ( #{25)   );

}
2
  • 2
    Can you show the HTML implementation of the button? Commented Aug 24, 2018 at 14:58
  • What do you mean by HTML implementation - a real life example of it? Commented Aug 25, 2018 at 9:39

2 Answers 2

4

You can use the "hover" properties same :

.btn:hover,
.btn:hover:before,
.btn:hover:after {
    background-color: #886633;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Wonderbar - I did try that but it didn't work - but now that I tried it using yours and added it to the top of the Custom CSS box, it HAS worked. Thank you!
1

This code should work .

.btn:hover {
 background-color: red;
 }
.btn:hover:before {
 background-color: red;
}
.btn:hover:after {
 background-color: red;
}

The only thing which was not clear was margin-left: calc( ( #{75) );. I have attached the codepen for the same . https://codepen.io/anon/pen/GXpbLo

1 Comment

Yes that has worked very well thank you Madhuri - that code: margin-left: calc( ( #{75) ); was causing an issue. Your attached revision has fixed the issue - many thanks for your time and consideration!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.