Button CSS transition does not work inside a DIV

Carlos Eduardo

All right? I'm having problems with an effect on CSS. Everything works perfectly until I put the code inside another div, and has a background that is not transparent. Look at the example below:

body {
  background: #2ecc71;
  padding:0;
  margin:0;
}

#bg{
  background: #000;
}
.container-button {
  padding: 10em;
  margin: 0 auto;
  width: 1170px;
  text-align: center;
  display: block;
  overflow: hidden;
}

/* GENERAL BUTTON STYLING */
.btn-more-info{
  display:block;
  overflow: hidden;
  text-align: center;
  display: inline-block;
  float: left;
}
.btn-more-info a,
.btn-more-info a::after {
  -webkit-transition: all 0.3s;
	-moz-transition: all 0.3s;
  -o-transition: all 0.3s;
	transition: all 0.3s;
  test-ident: -9999px;
  text-decoration: none;
}

.btn-more-info a {
  background: none;
  border: 2px solid #fff;
  border-radius: 5px;
  color: #fff;
  display: block;
  font-size: 14px;
  font-weight: bold;
  padding: 20px 50px;
  position: relative;
  text-transform: uppercase;
}

.btn-more-info a::before,
.btn-more-info a::after {
  background: #fff;
  content: '';
  position: absolute;
  z-index: -1;
}

.btn-more-info a:hover {
  color: #2ecc71;
}

/* BUTTON EFFECT */
.btn-effect {
  overflow: hidden;
}

.btn-effect::after {
  /*background-color: #f00;*/
  height: 100%;
  left: -35%;
  top: 0;
  transform: skew(50deg);
  transition-duration: 0.6s;
  transform-origin: top left;
  width: 0;
}

.btn-effect:hover:after {
  height: 100%;
  width: 135%;
}






.btn-send{
  overflow: hidden;
  text-align: center;
  clear: both;
}
.btn-send a,
.btn-send a::after {
  -webkit-transition: all 0.3s;
	-moz-transition: all 0.3s;
  -o-transition: all 0.3s;
	transition: all 0.3s;
  test-ident: -9999px;
  text-decoration: none;
}

.btn-send a {
  background: none;
  border: 2px solid #353B4C;
  border-radius: 5px;
  color: #353B4C;
  display: inline-block;
  font-size: 14px;
  font-weight: bold;
  padding: 20px 50px;
  position: relative;
  text-transform: uppercase;
}

.btn-send a::before,
.btn-send a::after {
  background: #353B4C;
  content: '';
  position: absolute;
  z-index: -1;
}

.btn-send a:hover {
  color: #FFF;
}
<div id="bg">
<div class="container-button">
  <div class="btn-more-info">
    <a href="" class="btn-effect">Continue lendo</a>
  </div>
  <div class="btn-send">
    <a href="" class="btn-effect">Enviar mensagem</a>
  </div>
</div>
</div>

You see, if you remove the id="bg" effect functions normally. Can anyone help me?

Thank U!

Joel Almeida

The problem is on the z-index of the :before and :after.

Try this:

.btn-more-info a::before,
.btn-more-info a::after {
    background: #fff;
    content: '';
    position: absolute;
    z-index: 0;
}

Also increase the z-index on the text inside the button.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

"\n" does not work inside an ASP:Button for Internet Explorer 10

分類Dev

Simple CSS transition does not execute

分類Dev

jquery hide div with CSS transition effect

分類Dev

CSS transition div width from center

分類Dev

Using a CSS Transition to slide a div in on load

分類Dev

CSS prevent multiple transition on div children

分類Dev

Android Back Button does not work ?

分類Dev

CSS - Problem of blured div inside a blured div

分類Dev

CSS: Button border gradient invert when transition on hover

分類Dev

CSS button transition linear-gradient background into transparent background

分類Dev

3D Button effect with CSS Drop-shadow and transition

分類Dev

Auto scroll div does not work

分類Dev

I have problem with CSS transition, it doesn't work on the first run

分類Dev

css3 transition on background image doesn't work in Firefox

分類Dev

Make invisible div work inside php loop

分類Dev

What is the advantage of using .btn class inside a <div> vs inside a <button>?

分類Dev

Javascript - Retrieving values of a div when a button inside that div is clicked

分類Dev

Why does this backreference not work inside a lookbehind?

分類Dev

Using a Picker in a Form inside an Sheet does not work

分類Dev

(android) Does getAdapterPosition() only work inside OnClick()?

分類Dev

JQuery Submit button does not work Laravel

分類Dev

If two radio button checked, add css to div

分類Dev

CSS transitions: Why won't my CSS transition work as I expect?

分類Dev

Transition button on slide but not on hover

分類Dev

CSS resizing div and images inside div on window resizing

分類Dev

How DIV & CSS work with Rowspan & Colspan?

分類Dev

Android Adding a button with multiline text inside MaterialButtonToggleGroup doesn't work

分類Dev

matplotlib Button click handler inside a function doesn't work

分類Dev

normal Button with onclick event inside a form doesn't work

Related 関連記事

  1. 1

    "\n" does not work inside an ASP:Button for Internet Explorer 10

  2. 2

    Simple CSS transition does not execute

  3. 3

    jquery hide div with CSS transition effect

  4. 4

    CSS transition div width from center

  5. 5

    Using a CSS Transition to slide a div in on load

  6. 6

    CSS prevent multiple transition on div children

  7. 7

    Android Back Button does not work ?

  8. 8

    CSS - Problem of blured div inside a blured div

  9. 9

    CSS: Button border gradient invert when transition on hover

  10. 10

    CSS button transition linear-gradient background into transparent background

  11. 11

    3D Button effect with CSS Drop-shadow and transition

  12. 12

    Auto scroll div does not work

  13. 13

    I have problem with CSS transition, it doesn't work on the first run

  14. 14

    css3 transition on background image doesn't work in Firefox

  15. 15

    Make invisible div work inside php loop

  16. 16

    What is the advantage of using .btn class inside a <div> vs inside a <button>?

  17. 17

    Javascript - Retrieving values of a div when a button inside that div is clicked

  18. 18

    Why does this backreference not work inside a lookbehind?

  19. 19

    Using a Picker in a Form inside an Sheet does not work

  20. 20

    (android) Does getAdapterPosition() only work inside OnClick()?

  21. 21

    JQuery Submit button does not work Laravel

  22. 22

    If two radio button checked, add css to div

  23. 23

    CSS transitions: Why won't my CSS transition work as I expect?

  24. 24

    Transition button on slide but not on hover

  25. 25

    CSS resizing div and images inside div on window resizing

  26. 26

    How DIV & CSS work with Rowspan & Colspan?

  27. 27

    Android Adding a button with multiline text inside MaterialButtonToggleGroup doesn't work

  28. 28

    matplotlib Button click handler inside a function doesn't work

  29. 29

    normal Button with onclick event inside a form doesn't work

ホットタグ

アーカイブ