Search code examples
cssscale

Transform scale in CSS - unexpected change font


My code after hover change style of font. It is probably related to this font: 14px/1.6 "Open Sans",sans-serif; but I need this. Is it possible to get this effect (scale to 1.2) in other way? Or change this CSS? My code.

.c-data:hover .liczba{
transform: scale(1.2, 1.2);
}

HTML

    <div class="u-div">
        <div class="c-data">
            <span class="liczba"></span>
        </div>
    </div>

Solution

  • Try this working snippet

    body {
      font: 14px/1.6"Open Sans", sans-serif;
    }
    .u-div {
      width: 25%;
      float: left;
      margin: 10px auto 20px auto;
    }
    .c-data {
      display: block;
      margin: 0px auto 0 auto;
    }
    .liczba {
      cursor: default;
      transition: all 0.2s;
      -webkit-transition: all 0.2s;
      -moz-transition: all 0.2s;
      -o-transition: all 0.2s;
      -ms-transition: all 0.2s;
      text-align: center;
      display: block;
      font-size: 80px;
      font-weight: bold;
      line-height: 80px;
    }
    .c-data:hover .liczba {
      font-size: 90px;
    }
    <div class="u-div">
      <div class="c-data">
        <span class="liczba">6</span>
      </div>
    </div>