简体   繁体   English

在鼠标悬停事件上需要帮助在div上添加带有箭头的标题

[英]Need help adding caption with arrow over a div on mouseover event

Regarding the hover effect, pelase check the site http://www.rokivo.com/ 关于悬停效果,请检查网站http://www.rokivo.com/

i want such a effect to be include for headings,buttons and div in mysite. 我希望将这种效果包括在mysite中的标题,按钮和div上。

thanks in advance 提前致谢

<div class="col-xs-12"> <a href="enquiry.html"><h3 class="orange2 pull-right contact-head">ENQUIRY<br/><i class="fa fa-arrow-right black arrow4 pull-left"></i></h3></a> </div>

i used jquery to add css transition class on mouseenter and remove that class on mouseleave but it looks odd. 我使用jquery在mouseenter上添加了CSS过渡类,并在mouseleave上删除了该类,但看起来很奇怪。 i want similar effect in the referral url above. 我想在上面的引荐网址中获得类似的效果。

It sounds like you didn't want to have the arrow sliding infinitely so I removed infinite also I added the longer arrow ( fa-long-arrow-right ) since you mentioned the "long arrow" in the comments. 听起来您不想让箭头无限滑动,所以我删除了infinite fa-long-arrow-right因为您在注释中提到了“长箭头”,所以我添加了更长的箭头( fa-long-arrow-right )。

I also added forwards so the arrow will stay at the end position of the animation and not go back to the beginning. 我还添加了forwards因此箭头将停留在动画的结束位置,而不会返回到开始。 This is the animation-fill-mode 这是动画填充模式

 .contact-head{ font-size:17px !important; padding:15px !important; border:2px solid #555 !important; border-bottom:5px solid #ffc000 !important; min-width:270px; max-width:270px; } @-webkit-keyframes arrow-jump3 { 0% { opacity: 0; -webkit-transform: translateX(25px); -moz-transform: translateX(25px); -0-transform: translateX(25px); transform: translateX(25px); } 100% { opacity: 1; -webkit-transform: translateX(160px); -moz-transform: translateX(160px); -0-transform: translateX(160px); transform: translateX(160px); } } .arrow4 { -webkit-animation: arrow-jump3 1s forwards; /* Safari 4+ */ -moz-animation: arrow-jump3 1s forwards; /* Fx 5+ */ -o-animation: arrow-jump3 1s forwards; /* Opera 12+ */ animation: arrow-jump3 1s forwards; /* IE 10+, Fx 29+ */ } .contact-head i{ display:none; } .contact-head:hover > i{ margin-top:10px; display:block; } .contact-head:hover{ background:#ffc000 !important; color:#000 !important; border-bottom:2px solid #555 !important; } .contact h3{ margin:20px 0px 20px 0px; font-size:19px; } a{ text-decoration:none; } 
 <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/> <div class="col-xs-12"> <a href="enquiry.html"><h3 class="orange2 pull-right contact-head">ENQUIRY<br/><i class="fa fa-long-arrow-right black arrow4 pull-left"></i></h3></a> </div> <div class="col-xs-12"> <a href="servicecall.html"><h3 class="orange2 pull-right contact-head">REGISTER SERVICE CALL<br/><i class="fa fa-long-arrow-right black arrow4 pull-left"></i></h3></a> </div> <div class="col-xs-12"> <a href="feedback.html"><h3 class="orange2 pull-right contact-head">CUSTOMER FEEDBACK<br/><i class="fa fa-long-arrow-right black arrow4 pull-left"></i></h3></a> </div> 

codepen 码笔

Hope this helps. 希望这可以帮助。 Good luck. 祝好运。

PS. PS。 Your codepen (arrow) wasn't working because you didn't include the font awesome css. 您的Codepen(箭头)无法正常工作,因为您未包含超棒的CSS字体。 You got to click on the cog icon and include your externals there. 您必须单击齿轮图标,并在其中包含外部组件。


Since you asked for me to look at the website I tried to do it the way I saw it. 由于您要我查看该网站,所以我尝试按照我的观察方式进行操作。 You might have to tweek it a little bit for your needs but for the most part it should give you an idea of how to accomplish your goal. 您可能需要为自己的需求花些时间,但在大多数情况下,它应该使您了解如何实现目标。 I didn't feel that there was a need to use keyframes so I used simple transitions on hover. 我觉得没有必要使用keyframes所以我在悬停时使用了简单的过渡。 when you hover over a parent you can also target a child and have that child transition. 当您将鼠标悬停在父母身上时,您还可以定位孩子并进行孩子过渡。 Hope you understand. 希望你能理解。

 *, *:after, *:before{ box-sizing:border-box; } .box{ position: relative; width: 200px; height: 300px; background: #eee; border-bottom: 5px solid #45ca58; transition: all .5s ease; margin: 0 auto; overflow: hidden; } .border{ width: 100%; height: 40px; display: inline-block; background: #45ca58; position: absolute; bottom: -40px; transition: all .5s ease; } /*on hover target the border element so that should move*/ .box:hover > .border{ position: absolute; bottom: 0px; } .arrow{ position: absolute; bottom: 10px; left:-20px; color:white; transition: all .5s ease-in-out; } .box:hover > .arrow{ left: 30px; } 
 <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/> <div class = "box"> <span class = "border"></span> <span class="arrow"><i class="fa fa-long-arrow-right"></i></span> </div> 

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

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