如何使用 CSS 转换将产品信息转换为视图

How to use CSS transforms to translate product info into view

我有一个促销容器,看起来像这样 -

将鼠标悬停在底部的白色条上时,它应该显示如下 -

我有一张底部白色容器的单独图片

我的标记如下 -

<div class="promo">
                    <div class="row">
                        <div class="col-md-12 col-xs-12 col-sm-12">
                            <div class="col-md-4 col-sm-4 col-xs-12 product">
                                <div class="img2 product-img"></div>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-12 product">
                                <div class="img3 product-img"></div>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-12 product">
                                <div class="img4 product-img"></div>
                            </div>
                        </div>
                    </div>
                </div>

而我的 CSS 如下 -

.promo {
  .row .product {
      padding: 0px 10px;
      .product-img {
          border: solid white 4px;
          background-size: cover;
          background-position: center;
          display: block;
          max-width: 100%;
          height: 260px;
      }
  }
  .img2 {
      background-image: url('../images/homepage/img2.png');
  }
  .img3 {
      background-image: url('../images/homepage/img3.png');
  }
  .img4 {
      background-image: url('../images/homepage/img4.png');
  }
  .img5 {
      background-image: url('../images/homepage/img5.png');
  }
}

我该怎么做,有人可以建议吗?

嗨,现在你可以试试这个了css

.first{float:left;width:200px;
height:200px;
overflow:hidden;
  position:relative;
border:solid 1px red;}
.pic{
background:url('https://www.gravatar.com/avatar/ce057f24ff1111404b60d1ad2d77571c?s=32&d=identicon&r=PG&f=1') no-repeat 0 0;background-size:100% 100%;
width:200px;
  height:200px;
}

.text{
position:absolute;
  left:0;
  right:0;
  height:40px;
  bottom:0;
  background: #2098d1;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  -webkit-transition-property: color;
  transition-property: color;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
}
.text:before{
content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #2098d1;
  -webkit-transform: scaleY(0);
  transform: scaleY(0);
  -webkit-transform-origin: 50% 100%;
  transform-origin: 50% 100%;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.first:hover .text{
 height:120px;
}
.first:hover .text:before{
  -webkit-transform: scaleY(1);
  transform: scaleY(1);
}
<div class="first">
  <div class="pic"></div>
  <div class="text">
    <p>Hello i m text</p>
    <h3>Heading</h3>
    <p>Hi now again text</p>
  </div>
</div>