简体   繁体   English

当鼠标悬停在按钮上方时,如何使按钮具有弹出效果以及边框具有白色阴影

[英]How to make button have a pop-up effect and border to have a white shadow when mouse hover above the button

Functionality: 功能:

The Button should have the following effect when user hover above the button: 当用户将鼠标悬停在按钮上方时,该按钮应具有以下效果:

  • The Button should have a pop-up effect. 该按钮应具有弹出效果。
  • The Button border should have white shadow effect. 按钮边框应具有白色阴影效果。

What has been done: 已经做了什么:

I have made use of 我已经利用了

img:hover{
            border-color: white;
        }

to try to get the effect of the a border shadow of white. 尝试获得白色边框阴影的效果。

Issue: 问题:

I can't really seem to get the said effect. 我似乎无法真正获得上述效果。 However, I was able to get the effect such as this : 但是,我能够得到这样的效果:

img:hover{
            background-color: white;
        }

when user hover above the button. 当用户将鼠标悬停在按钮上方时。

Hence, how am I able to create the css such that when user hover above the button, it will create the said effect. 因此,我如何创建CSS,以便当用户将鼠标悬停在按钮上方时,它将创建上述效果。

Thanks. 谢谢。

 img:hover { border-color: white; } #Button1 { position: absolute; top: 310px; left: 1550px; outline: 0px; z-index: 2; border: 0; background: transparent; } 
 <button id="Button1" onclick="GreatLoveInSingapore()"> <img src="lib/img/GreatLoveButton.png"> </button> 

Here's a link that can help you. 这是一个可以帮助您的链接。

http://ianlunn.github.io/Hover/ http://ianlunn.github.io/Hover/

this page has a collection of over effects. 此页面有过度效果的集合。

If you want just to grow up your button you should use transfrom it allow you to scale your button 如果您只想长大按钮,则应使用transfrom来缩放按钮

 div{ margin: 50px 200px; } button{ border: 0; padding: 0; cursor: pointer } img { height: 100px; width: 100px; display: block; transition: 0.7s; } img:hover{ transform: scale(1.2); } 
 <div> <button class="container"> <img src="http://i.imgur.com/IMiabf0.jpg"> </button> </div> 

EDIT: another way if you have img not text 编辑:另一种方式,如果您有img不是文字

 div.container { text-align: center; margin: 100px auto 0; } a { display: inline-block; background-color: #1984c3; color: #fff; font-size: 1.5em; font-family: 'Calibri', sans-serif; font-weight: lighter; padding: 1em 2em; text-decoration: none; text-transform: uppercase; -moz-transition: 0.3s; -webkit-transition: 0.3s; transition: 0.1s; } a:hover{ transform: scale(1.2); } 
 <div class="container"> <a href="#">Hi Im a Button</a> </div> 

Example of padding.... 填充示例...

 button{ transition: padding 1s; } button:hover { box-shadow: 0px 5px 5px #888888; padding:15px; } 
 <button><img src="#"/></button> 

Transition is used to give the button an animated stretch and box-shadow for the pop-out effect. 过渡用于为按钮赋予动画的拉伸和阴影,以实现弹出效果。 This is just a quick example mainly to focus on the padding. 这只是一个快速示例,主要关注于填充。

I'm sure you can expand on this applying more styles to fit your needs. 我相信您可以在此基础上扩展样式,以应用更多样式来满足您的需求。 Any questions please leave a comment below and I will get back to you as soon as possible. 如有任何问题,请在下面留下评论,我会尽快与您联系。

I hope this helps. 我希望这有帮助。 Happy coding! 编码愉快!

暂无
暂无

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

相关问题 按钮具有特定类别时弹出窗口 - pop-up window when button have specific class 如何具有多个具有相同ID值的按钮,并且单击任何按钮时都应该弹出窗口? - How to have multiple buttons of same id value and when click on any button the pop-up should come? 弹出式Div出现在按钮的悬停上 - Pop-up Div to appear on hover of button 如何重新创建此背景淡入/弹出效果图标按钮? - How to recreate this background fade in/pop-up effect icon button? 如何使Google预览按钮在CSS弹出窗口中显示? - How to make Google Preview Button display in a CSS pop-up? 无法立即在弹出窗口中“按下”刚刚创建的按钮。 我必须关闭弹出窗口,然后再次打开它(chrome-extension弹出窗口) - Cannot 'press' a just created button inside a pop-up window immediately. I have to close the pop-up and then open it again (chrome-extension pop-up) 阴影背景,并在出现弹出窗口时使其无法点击 - Shadow background and make it unclickeble when pop-up occurs 当鼠标悬停在浏览器栏/后退按钮上时,JavaScript弹出 - Javascript Pop-Up when Mouse Hovers toward Browser Bar/Back Button 如何在悬停时制作弹出标题卡? - How to Make Pop-Up Title Card on Hover? 将鼠标悬停在html表格单元格上,并在将鼠标悬停在html表格单元格上时弹出图像,并在光标移开时消失 - Hover over an html table cell and have an image pop-up using javascript while hovering over it and disappear when the cursor is moved away
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM