热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

HTML/CSS-悬停过渡问题-HTML/CSS-OnHoverTransitionissue

firstlyheresthefiddle:http:jsfiddle.netkrish7878C7D89首先是小提琴:http:jsfiddle.netkrish78c

firstly here's the fiddle: http://jsfiddle.net/krish7878/C7D89/

首先是小提琴:http://jsfiddle.net/krish78/c7d89/

There is a container with a image in it, it also has a div with class 'overlay'. What I am trying to achieve is, on mouse hover the circle should be filled with the overlay. It is getting filled but it also shows an awkward from square to circle. How do I get rid of it.

有一个包含图像的容器,它还有一个div,类为“叠加”。我想要实现的是,在鼠标悬停的时候,圆圈应该布满了覆盖。它正在填充,但它也显示了一个尴尬的从正方形到圆形。我怎样才能摆脱它呢?

HTML Code:

HTML代码:

CSS code:

CSS代码:

 .container{
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 100%;
    overflow: hidden;
    margin: 0 auto;
    }
 .overlay{
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #49c8ff;
    opacity: 0;
    top: 0px;

transition:         all 300ms ease;;
                    -moz-transition:    all 300ms ease;
                    -webkit-transition: all 300ms ease;
                    -o-transition:      all 300ms ease;
                    -ms-transition:     all 300ms ease;
  }
.container:hover .overlay{
    opacity: 1;
 }   

2 个解决方案

#1


3  

You just need to apply border-radius to the .overlay div also.

你只需要将边界半径应用到。overlay div。

.overlay{
    border-radius: 50%;
}

Working FIDDLE

工作小提琴

#2


2  

Simply apply the same border radius to the overlay element. Also, since radius is half of the diameter, declaring a border radius of 50% is sufficient :)

只需对覆盖元素应用相同的边框半径。此外,由于半径是直径的一半,因此声明边界半径为50%就足够了:

.overlay{
    border-radius: 50%;
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #49c8ff;
    opacity: 0;
    top: 0px;
    transition:         all 300ms ease;
                        -moz-transition:    all 300ms ease;
                        -webkit-transition: all 300ms ease;
                        -o-transition:      all 300ms ease;
                        -ms-transition:     all 300ms ease;
}

See fiddle here: http://jsfiddle.net/teddyrised/C7D89/2/

看到小提琴:http://jsfiddle.net/teddyrised/C7D89/2/


推荐阅读
author-avatar
等着日落看日出222
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有