简体   繁体   English

跨浏览器独特的形状链接

[英]Cross-Browser Unique Shaped Link

I'm working on a web app that will allow users to enter content and then submit it out to people's phones. 我正在开发一个网络应用程序,允许用户输入内容,然后将其提交给人们的手机。 It works like a charm, but I'm having some problem with the logo. 它就像一个魅力,但我对徽标有一些问题。 The logo is the following: 徽标如下:

在此输入图像描述

I have a button on the left that is a different link, which is why we don't want the logo link to cover it up. 我左边有一个不同的链接按钮,这就是为什么我们不希望徽标链接覆盖它。

My first idea was to use a border-radius, but the angle at the bottom is too sharp for that. 我的第一个想法是使用边界半径,但底部的角度太尖锐了。 For example, if I use a border radius of: 0 0 75px 75px, it does the following: 例如,如果我使用的边界半径为:0 0 75px 75px,则执行以下操作:

在此输入图像描述

So, if we make the angles bigger, let's say to: 0 0 100px 100px, it does the following: 所以,如果我们使角度更大,让我们说:0 0 100px 100px,它执行以下操作:

在此输入图像描述

(There's no difference.) (没有区别。)

If I increase the bottom left, it pushes out the bottom right, and vice versa. 如果我增加左下角,则向右推动,反之亦然。 I ended up doing the following because there's no link on the right side. 我最终做了以下事情,因为右侧没有链接。

在此输入图像描述

There's still a small, minor space on the left, but it's way better. 左边还有一个小的小空间,但它更好。 Except now there's a big link on the right, which might bother the end user because there shouldn't be anything there. 除了现在右边有一个很大的链接,这可能会打扰最终用户,因为那里不应该有任何东西。

So, we chose to use image maps and did the following: 因此,我们选择使用图像映射并执行以下操作:

在此输入图像描述

And that works! 这有效! ... kinda. ......有点儿 The bottom left corner of the image now, above the red link, is a dead space. 图像的左下角现在位于红色链接上方,是一个死角。 So, an alternative is we then make the bottom corner a different link. 因此,另一种方法是我们将底角设为不同的链接。 Let me illustrate. 让我来说明一下。

在此输入图像描述

That fixes that. 这解决了这个问题。 Until the user scrolls. 直到用户滚动。 As you can see, the logo (and header) are fixed. 如您所见,徽标(和标题)是固定的。 The navigation is not. 导航不是。 The following then happens. 然后发生以下情况。

在此输入图像描述

I'm using jQuery so it won't be hard then to get the distance scrolled, compare it to what navigation item is in that area and change that section of the image map to match it... but I feel I'm overkilling this. 我正在使用jQuery,因此滚动距离并不难,将其与该区域中的导航项进行比较,并更改图像映射的那一部分以匹配它...但我觉得我太过分了这个。

(And then, to top it off, different users have a different navigation...) (然后,最重要的是,不同的用户有不同的导航......)

Do you know of a similar solution? 你知道类似的解决方案吗? Or am I stuck with image maps and jquery link changes? 或者我坚持使用图像映射和jquery链接更改?

Thanks a lot! 非常感谢!

Edit: To confirm the "dead space" I was linking to, please review the image below: 编辑:要确认我正在链接的“死角”,请查看下图:

在此输入图像描述

Even though the image map is around the shield, the shield is still an image and has square corners, leaving the corners an unlinkable area, unless another image map is made for that area. 即使图像映射在屏蔽周围,屏蔽仍然是图像并且具有方角,使角落成为不可链接的区域,除非为该区域制作另一个图像映射。 I did that, but because the navigation scrolls, that linked area no longer matches the navigation below it. 我做到了,但由于导航滚动,该链接区域不再匹配它下面的导航。 A border-radius on the image map would kind of fix the issue also, but I've gone with a different approach. 图像地图上的边界半径也可以解决问题,但我采用了不同的方法。

Hopefully that answers the question! 希望能回答这个问题!

You might be able to revisit your CSS approach with this CSS3 badge shape technique: 您可以使用此CSS3徽章形状技术重新访问CSS方法:

http://jsfiddle.net/isherwood/2v2wM http://jsfiddle.net/isherwood/2v2wM

#shield {
    position: relative;
    width: 140px;
    height: 100px;
    background-color: navy;
    border-radius: 0 0 50px 50px;
    display: inline-block;
}
#shield:before, #shield:after {
    position: absolute;
    margin-top: 30px;
    content:"";
    left: 70px;
    top: 0;
    width: 70px;
    height: 115px;
    background: navy;
    border-radius: 50px 50px 0 0;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg);
    -webkit-transform-origin: 0 100%;
    -moz-transform-origin: 0 100%;
    -ms-transform-origin: 0 100%;
    -o-transform-origin: 0 100%;
    transform-origin: 0 100%;
}
#shield:after {
    left: 0;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(45deg);
    -webkit-transform-origin: 100% 100%;
    -moz-transform-origin: 100% 100%;
    -ms-transform-origin: 100% 100%;
    -o-transform-origin: 100% 100%;
    transform-origin :100% 100%;
}

The shape's not quite right, but with some adjustments it should work nicely. 形状不太正确,但通过一些调整它应该很好地工作。

To elaborate on my comment, you can add href links directly to the image map elements: 要详细说明我的评论,您可以直接将href链接添加到图像映射元素:

<img src="logo.jpg" usemap="#logo" border="0">
<map name="logo">
  <area shape="polygon" coords="[long list of coordinates]" href="www.mylink.com">
</map>

Not sure if I'm missing something in your example... 不确定我是否遗漏了你的例子......

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

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