1

Here's the snippet of my transition on my card component. I have a transition when it's being hovered on the box-shadow. It seems smooth when it is being hovered out but not when it's being hovered in (seems a bit sharp).

What did I miss in my css?

Here's my fiddle - https://jsfiddle.net/zxfb981r/

.wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  height: 7.75rem;
  transition: all 300ms;
  box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
  border: solid 1px #F5F5F5;
}
.wrapper:hover{
  box-shadow: 0 2px 14px 0 rgba(0, 0, 0, 0.4);
  transition: opacity 200ms ease-in-out;
}
.imageContainer {
  flex: 0 0 33%;
  height: 100%;
}

.image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content {
  flex: 1;
  text-align: left;
  margin: 0 1.1825rem;
}

.title {
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
  padding: 0;
}

.price {
  color: #BAA082;
  font-size: 0.875rem;
  text-transform: uppercase;
  margin: 2rem 0 0;
  padding: 0;
}

@media(min-width: 46.5rem) {
  .wrapper {
    height: 8.75rem;
  }
  .title {
    font-size: 1.1875rem;
  }
  .price {
    font-size: 1rem;
  }
}
<div class="wrapper">
  <div class="content">
    <h4 class="title">Point of sale</h4>
    <p>Point of sale</p>
    <p class="price">From £165</p>
  </div>
  <div class="imageContainer">
    <img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=2134&amp;q=80" alt="" class="image"></div>
</div>

1
  • Please explain what you mean by sharp. Commented Sep 27, 2019 at 11:36

1 Answer 1

2

Remove the opacity from transition will give you desire result. check snippet.

.wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  height: 7.75rem;
  transition: all 300ms;
  box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
  border: solid 1px #F5F5F5;
}
.wrapper:hover{
  box-shadow: 0 2px 14px 0 rgba(0, 0, 0, 0.4);
  transition: 200ms ease-in-out;
}
.imageContainer {
  flex: 0 0 33%;
  height: 100%;
}

.image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content {
  flex: 1;
  text-align: left;
  margin: 0 1.1825rem;
}

.title {
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
  padding: 0;
}

.price {
  color: #BAA082;
  font-size: 0.875rem;
  text-transform: uppercase;
  margin: 2rem 0 0;
  padding: 0;
}

@media(min-width: 46.5rem) {
  .wrapper {
    height: 8.75rem;
  }
  .title {
    font-size: 1.1875rem;
  }
  .price {
    font-size: 1rem;
  }
}
<div class="wrapper">
  <div class="content">
    <h4 class="title">Point of sale</h4>
    <p>Point of sale</p>
    <p class="price">From £165</p>
  </div>
  <div class="imageContainer">
    <img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=2134&amp;q=80" alt="" class="image"></div>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.