Hover with Scale only in father div

Asked

Viewed 159 times

0

Next person I own a div Father and inside her others divs I wanted to apply a css where to change the background to purple and the text and image to white until then works normal the problem is that wanted to apply a scale at the bottom that turned purple with the :hover more doing so it applies the effect of :hover the other elements and in this case wanted the effect of scale stay only at the bottom. follow my code:

OBS I am using SASS attached an image to show the final result.

SASS

.box-courses{
    border: 2px solid $gray-light;
    padding: 15px 30px;
    @include transition(.5s);

    &:hover{
      @include gradient-bg(gradient);
      @include box-shadow(shadow);
      @include scale(1.1);
      border: none; 
      .title-course{
         @include scale(1);
        color: $white;
      }

      .icon-course{
         @include scale(1);
        background-image: url(../images/courses/html-hover.png);
      }

      .description{
         @include scale(1);
        color: $white;
      }
    }

    .title-course{
      font-family: 'Open Sans', sans-serif;
      font-size: 15px;
      font-weight: bold;  
      color: $gray;
    }

    .icon-course{
      background-image: url(../images/courses/html.png);
      width: 52px;
      height: 57px;
    }

    .description{
      font-size: 13px;
    }
    .buttons{
      margin-top: 15px;
      li{
        .btn-custom{
          padding: 10px 15px;
        }
      }
    }
  }

HTML

<div class="container">
        <div class="row">
            <div class="col-md-4">
                <div class="box-courses">
                    <div class="row">
                        <div class="col-md-3 pull-right">
                            <div class="icon-course"></div>
                        </div>
                        <div class="col-md-9">
                            <h4 class="title-course">Curso de HTML5: Aprenda de maneira descomplicada.</h4>
                        </div>

                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <p class="description">
                                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                            </p>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <ul class="list-inline list-unstyled buttons">
                                <li><a href="#" class="btn-gradient btn-custom">Saiba mais</a></li>
                                <li><a href="#" class="btn-white btn-custom"><span>Comprar curso agora</span></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

the layout inserir a descrição da imagem aqui

my code realize here that font and other elements have increased and that’s not what I just want to increase the purple background: inserir a descrição da imagem aqui

1 answer

2


There is a technique that while you do the Scale Up at the Father at the same time you make a Scale Down on son. (I will not do with your SASS pq I have no compiler). Ma follows a practical example.

This example can help you understand the concept of technique.

.box-courses {
    background-color: red;
    width: 80%;
    transform: scale(1);
    transition: transform 0.5s linear;
    /* box-sizing: border-box; */
}
.box-courses:hover {
    transform: scale(1.1);
}
.box-courses .small{
    transform: scale(1);
    transition: transform 0.5s linear;
}
.box-courses:hover .small{
    transform: scale(0.9);
}
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<div class="container">
    <div class="row">
        <div class="col-md-4">
            <div class="box-courses">
                <div class="small">
                    <h1>gdfg</h1>
                    <img src='http://placeskull.com/80/80' alt=''/>
                </div>
            </div>
        </div>
    </div>
</div>

  • There’s a mathematical problem there. 0.9 is not the "opposite" of 1.1 - If it increased 1.1, the inverse is 0.909090909090909... (another example: if you increase a value by 25%, you have to decrease only 20% for it to return to the original)

  • @Bacco xD true! I just don’t know if it checks out, but these days I’ve heard that CSS only understands up to 4 decimal places, 0.0001 after that it ignores....

  • @Bacco already found a reference, the number of decimals would make from Browser to Browser. I think I’ll even ask a question about it to get registered on the site look ai http://cruft.io/posts/percentage-calculations-in-ie/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.