StackUnderFlow
StackUnderFlow

Reputation: 367

Link hover not working - CSS

I'm trying to scale a box by hovering over it but doesn't seem to be working. Can I style the href to scale when hovering over?

Got the code I'm using below as well as a jsfiddle: https://jsfiddle.net/695e7ca9/

HTML:

<div class="window">
  <div class="col">
    <a href="google.com" class="box">
      <span class="title-label">window title </span>
      <span class="content"></span>
    </a>
  </div>
</div>

CSS:

.col {
  max-width: 50%;
}

.title-label {
  display: block;
  padding: 20px;
  margin-bottom: 0;
  color: #fff;
  font-weight: 700;
  background: #0176ff;
  -moz-border-radius: 4px 4px 0 0;
  -webkit-border-radius: 4px;
  border-radius: 4px 4px 0 0;
}

.content {
  margin-top: -1px;
  box-shadow: inset 0 0 0 1px #0176ff;
  border-top: 0;
  padding: 25px;
  min-height: 235px;
  display: block;
}

.window .col .box:hover {
  -moz-transform: scale(1.1);
  -ms-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
  -moz-box-shadow: 0 0 49px rgba(0, 0, 0, .06);
  -webkit-box-shadow: 0 0 49px rgba(0, 0, 0, .06);
  box-shadow: 0 0 49px rgba(0, 0, 0, .06);
}

Upvotes: 1

Views: 2200

Answers (1)

sandrina-p
sandrina-p

Reputation: 4160

It doesn't work because it's an <a>, an inline element.

You need to add display:block to make it work.

Also I added transition: transform 250ms to add some "smoothness" to the animation.

https://jsfiddle.net/695e7ca9/3/

Upvotes: 5

Related Questions