简体   繁体   English

当鼠标悬停在图像上时显示放大的图片时平滑过渡

[英]Smooth transition when show enlarged picture in mouse hover over an image

I am new in HTML, CSS.我是 HTML、CSS 的新手。 I want to have hover effect on an image in my website.我想在我的网站上的图像上有悬停效果。 The code is kind of working.该代码是一种工作。 However, when it ease out it is not as smooth as when it get enlarged.然而,当它缓出时,它不像放大时那么平滑。 I want a smooth transition in both ways.我希望双方都能顺利过渡。 Here I submit my css and html code.在这里,我提交了我的 css 和 html 代码。 There is a big chance many things are wrongly or inefficiently used here.很多东西在这里被错误地或低效地使用的可能性很大。 It would be really great if someone can help me out with this.如果有人能帮我解决这个问题,那就太好了。

CSS CSS

.about .block h2 {
padding-top: 35px;
padding-bottom: 20px;
margin: 0;
}

.about .block h4 {
font-size: 20px;
text-align: justify;
}

/*----------------------*/
.about .block img {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
border-radius: 50%;
}

.about .about-img {
overflow: hidden;
}

.about .about-img:hover img {
-webkit-transform: scale3D(1.1, 1.1, 1);
transform: scale3D(1.1, 1.1, 1);
}

.about .about-img img {
opacity: 1;
transition: all 0.2s ease-in-out;
}

.effect {
border: none;
margin: 0 auto;
}

.effect:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}

HTML HTML

    <section class="about">
    <div class="container">
        <div class="row">
            <div class="col-md-7 col-sm-12">
                 <div class="block">
                    <div class="section-title">
                        <h2>ABOUT X</h2>
                    </div>
                    <h4> Here I will write some text next to the circular image. I want enlarged picture when mouse hover over on the image.
                   </h4>
                </div>
              </div>
            </div>
            <!-- .col-md-7 close -->
            <div class="col-md-5 col-sm-12">
                <div class="block">
                    <img class="effect" src="image.jpg" alt="Img">
                </div>
            </div>
            <!-- .col-md-5 close -->
        </div>
    </div>
</section>

I think your problem lies on .effect class我认为你的问题在于.effect

You should have include the transition property on your .effect class您应该在.effect类中包含 transition 属性

.effect {
  border: none;
  margin: 0 auto;
  -webkit-transition: all 0.4s ease-in-out;
  -moz-transition: all 0.4s ease-in-out;
  -o-transition: all 0.4s ease-in-out;
  transition: all 0.4s ease-in-out;
}

That should do the transition when leaving your hover state.这应该在离开悬停状态时进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM