点击图片就能浏览的超链接HTML5怎么写?

点击图片就能浏览的超链接HTML5怎么写?,第1张

使用HTML <map>标签,给图片设置热点(指定的要添加链接的地方)

例子:

<img src="planets.jpg" border="0" usemap="#planetmap" alt="Planets" border="0" />

<map name="planetmap" id="planetmap">

<area shape="circle" coords="180,139,14" href ="venus.html" style="cursor: pointer" alt="Venus" />

<area shape="circle" coords="129,161,10" href ="mercur.html" alt="Mercury" />

<area shape="rect" coords="0,0,110,260" href ="sun.html" alt="Sun" />

</map>

关于例子的解释:

area 元素永远嵌套在 map 元素内部。area 元素可定义图像映射中的区域。

<img>中的 usemap 属性可引用 <map>中的 id 或 name 属性(取决于浏览器),所以应同时向 <map>添加 id 和 name 属性。

x1,y1,x2,y2

如果 shape 属性设置为 "rect",则该值规定矩形左上角和右下角的坐标

x,y,radius

如果 shape 属性设置为 "circ",则该值规定圆心的坐标和半径。

x1,y1,x2,y2,..,xn,yn

如果 shape 属性设置为 "poly",则该值规定多边形各边的坐标。如果第一个坐标和最后一个坐标不一致,那么为了关闭多边形,浏览器必须添加最后一对坐标。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>Transform</title>

<style type="text/css">

.test-box{

width:600px

margin:50px auto}

.pic{

-webkit-transition:all 1s ease-in-out

transition:all 1s ease-in-out

cursor:pointer}

.top-pic{

position:absolute

transform:scale(0,0)}

.test-box:hover .top-pic{

-webkit-transform-origin:top right

-webkit-transform:scale(1,1)}

.test-box:hover .bot-pic{

-webkit-transform:scale(0,0)

-webkit-transform-origin:bottom left

opacity: .5

-webkit-transform:rotate(120deg)

-webkit-transform-origin:bottom left

}

</style>

</head>

<body>

<div class="test-box">

<img class="pic top-pic" src="test-pic01.jpg" />

<img class="pic bot-pic" src="test-pic02.jpg" />

</div>

</body>

</html>

随便写了几个效果,没有用到JS,不过要用到JS只要把触发事件替换掉上面的hover就行了,比如:

$(".button").click(function () {

。。。

})

这里面用到CSS3,所以请不要用IE11以下的低版本浏览器,不然你啥都看不见


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7388253.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存