Randy Tang
Randy Tang

Reputation: 4353

CSS3 transform: scaling results in translation?

I have the following simple HTML code:

<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8>
    <style>
      body {
        padding: 30px;
      }
      a {
        display: block;
      }
      a:hover {
        transform: scale(2); 
        transition: all 4s;
      }
    </style>
  </head>
  <body>

    <a href=#>Link</a>

  </body>
</html>

in which the Link is supposed to scale. However, it shifts to the left. What is the problem?

Upvotes: 3

Views: 53

Answers (1)

vanntile
vanntile

Reputation: 2787

body {
  padding:30px;
}
a {
  display: inline-block;
  transition: all 4s;
}
a:hover {
  transform: scale(2); 
}
<a href=#>Link</a>

You should have used display:inline-block to make it work. If it is what you are looking for, +1.

Upvotes: 4

Related Questions