[英]Create custom shape background image on Menu hover using css and jquery
Navigation Menu 导航菜单
I have navigation menu and want to add image on active and hover like this screenshot,and it should set properly if menu text is long or short. 我有导航菜单,并希望像此屏幕截图一样在活动菜单和悬停菜单上添加图像,并且如果菜单文本是长还是短,都应该正确设置。
My HTML makup is as given below, i have used images to acheive the custom shape when the link is active, but i dono how to acheive this for hover. 我的HTML makup如下所示,当链接处于活动状态时,我使用图像来实现自定义形状,但是我不知道如何进行悬停。 Please help. 请帮忙。
ul#navigation li {
float: left;
list-style: none outside none;
}
ul li a {
color: #000000;
text-decoration: none;
}
ul#navigation li.left_bg.starter_active {
background: url("http://new.nsracing.ch/themes/nsracing/images/btn_left.png") no-repeat scroll 0 center transparent;
height: auto;
padding: 0 0 0 28px;
width: auto;
}
ul#navigation li .right_bg.starter_active {
background:url("http://new.nsracing.ch/themes/nsracing/images/btn_rght.png") no-repeat scroll 100% center transparent;
float: left;
height: auto;
padding-right: 23px;
}
ul#navigation li a.starter_active {
background: url("http://new.nsracing.ch/themes/nsracing/images/btn_cntr.png") repeat-x scroll 0 0 transparent;
padding: 9px 0 6px;
}
is there any way to make such shape using any css or jquery? 有没有办法使用任何CSS或jquery做出这样的形状?
You need to use CSS Transform
with border-radius
to achieve what you are looking for. 您需要将CSS Transform
与border-radius
以实现所需的功能。 You can read more about the same below. 您可以在下面阅读更多有关此内容的信息。
https://developer.mozilla.org/en-US/docs/Web/CSS/transform - For Transform https://developer.mozilla.org/es/docs/CSS/border-radius - For border-radius https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-用于变换https://developer.mozilla.org/es/docs/CSS/border-radius-用于border-radius
Hope this helps. 希望这可以帮助。
像是平行四边形
ul#navigation li.a:hover{ width: Xpx; height: Ypx; -webkit-transform: skew(zdeg); -moz-transform: skew(zdeg); -o-transform: skew(zdeg); background: yellow; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.