【发布时间】:2019-09-08 23:38:41
【问题描述】:
我有以下菜单需要稍微旋转一下:
(来源:maroonlemoon.com)
我已经设法为每个菜单条使用嵌套 div 来实现外观(容器 div 具有黄色背景图像,嵌入式 div 具有链接到带有每个菜单部分文本的图像的背景图像)
<div id="the-menu" style="position:absolute; z-index:9998; left:120px; top:-5px; width:255px; height:300px;">
<div id="home-strip" align="right" style="position:absolute; z-index:1; left:0px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div onclick="javascript:alert('home');" style="cursor:pointer; position:relative; width:90px; height:35px; top:9px; left:6px; background-image:url('images/menu-text.png');"></div>
</div>
<div id="about-strip" align="right" style="position:absolute; z-index:2; left:10px; top:30px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div onclick="javascript:alert('about');" style="cursor:pointer; position:relative; width:90px; height:35px; top:10px; left:4px; background-image:url('images/menu-text.png'); background-position: 0px -38px; background-repeat:no-repeat"></div>
</div>
<div id="classes-strip" align="right" style="position:absolute; z-index:3; left:20px; top:60px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div style="cursor:pointer; position:relative; width:90px; height:35px; top:6px; left:4px; background-image:url('images/menu-text.png'); background-position: 0px -76px; background-repeat:no-repeat"></div>
</div>
<div id="team-strip" align="right" style="position:absolute; z-index:4; left:30px; top:90px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div style="cursor:pointer; position:relative; width:90px; height:37px; top:7px; left:4px; background-image:url('images/menu-text.png'); background-position: 0px -116px; background-repeat:no-repeat"></div>
</div>
<div id="facilities-strip" align="right" style="position:absolute; z-index:5; left:40px; top:120px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div style="cursor:pointer; position:relative; width:90px; display:block; height:40px; top:10px; left:-3px; background-image:url('images/menu-text.png'); background-position: 6px -157px; background-repeat:no-repeat"></div>
</div>
<div id="schedule-strip" align="right" style="position:absolute; z-index:6; left:50px; top:150px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div style="cursor:pointer; position:relative; width:90px; display:block; height:35px; top:10px; left:4px; background-image:url('images/menu-text.png'); background-position: 0px -196px; background-repeat:no-repeat"></div>
</div>
<div id="contact-strip" align="right" style="position:absolute; z-index:7; left:60px; top:180px; width:216px; height:112px; background-image:url('images/menu-sliced.png'); background-position: 0px 0px;">
<div style="cursor:pointer; position:relative; width:90px; display:block; height:40px; top:10px; left:-5px; background-image:url('images/menu-text.png'); background-position: 8px -234px; background-repeat:no-repeat"></div>
</div>
</div>
不要介意内联样式。我的问题是我想为每个菜单部分(带有角度)创建悬停和单击状态,但是使用原生 HTML 实现这一点似乎有点挑战性,因为 div 会相交。请参阅以下快照以进行说明:
(来源:maroonlemoon.com)
您的帮助将不胜感激,我想要一个适用于所有主要浏览器的解决方案(我研究了一个 jQuery 插件,它可以做到这一点,但不兼容跨浏览器)我应该使用经典的 html 热点来做到这一点.我有点讨厌使用它们,并且觉得它们不再用于此目的
【问题讨论】:
-
您考虑过只使用图像映射吗?它们的存在时间几乎与互联网一样长,而且使用起来比较简单;你只需要一张图像,你就可以以任何你想要的角度绘制任意复杂的多边形。它们得到普遍支持 - 第一个支持是在 Mosaic 1.1 中!对于超级花哨的东西,您可以使用 Imagemapster:outsharked.com/imagemapster(我已经设计了包含这两种技术的完整 HTML5 应用程序,并且可以正常工作)
标签: javascript jquery html css