当我将鼠标悬停在矢量的一部分上时,如何放大图像?
How can I enlarge an image when hovering over part of a vector?
我在页面左上角设置了一个按钮,主要是在屏幕外,它的功能是home键。我想稍微增加它的大小时,悬停,但没有我尝试似乎工作。
看到的图像是一个矢量(感谢上帝)是一个完美的圆。有了area标签,我可以很容易地把它做成home键。现在我想放大图像,当鼠标悬停在该区域标签,我已经尝试使用'+'选择器。
我怎么做这样的事情?
这是一个上下文代码片段:
.emblem {
width: 200px;
height: 200px;
position: absolute;
margin: -100px 0px 0px -80px;
z-index: 2;
opacity: 0.9;
}
.emblem:hover {
width: 220px;
height: 220px;
}
.emblem2 {
visibility: hidden;
width: 220px;
height: 220px;
}
area:hover + .emblem2 {
visibility: visible;
}
<map name="homemap">
<area shape="circle" coords="100,100,100" alt="Home button" href="index.html" />
</map>
<img class="emblem" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="UFF emblem" usemap="#homemap" />
<img class="emblem2" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="UFF emblem" usemap="#homemap" />
现在这个工作很好…但是只有当我将鼠标悬停在图像的透明部分时,我想要实现的是完全相反的效果。
你可以尝试改变你想要放大的图像的比例。像这样:
.emblem {
width: 200px;
height: 200px;
opacity: 0.9;
position: relative;
-webkit-transition: all 200ms ease-in;
-webkit-transform: scale(1);
-ms-transition: all 200ms ease-in;
-ms-transform: scale(1);
-moz-transition: all 200ms ease-in;
-moz-transform: scale(1);
transition: all 200ms ease-in;
transform: scale(1);
}
.emblem:hover{
-webkit-transition: all 200ms ease-in;
-webkit-transform: scale(1.5);
-ms-transition: all 200ms ease-in;
-ms-transform: scale(1.5);
-moz-transition: all 200ms ease-in;
-moz-transform: scale(1.5);
transition: all 200ms ease-in;
transform: scale(1.5);
}
<img class="emblem" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="UFF emblem" usemap="#homemap" />
使用CSS:
.img-box {
cursor: pointer;
height: 110px;
position: relative;
width: 110px;
}
.img-link {
color: #000;
text-decoration: none;
}
.img-link a,
.img-link a:active,
.img-link a:focus,
.img-link a:hover {
border-color: transparent;
color: #000;
text-decoration: none;
}
.fa-hover {
bottom: 0;
font-size: x-large;
position: absolute;
right: 0;
}
.fa-hover:hover + .emblem {
height: 100px;
width: 100px;
}
.emblem {
height: 75px;
width: 75px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="img-box">
<a class="img-link" href="https://www.google.ca" target="_window">
<div class="fa-hover">
<span class="fa fa-plus"></span>
</div>
<img class="emblem" src="https://lh3.ggpht.com/A0x3jzuH1qRkE10HcTiT4qQr_6iAqVg-CTsoIqxnoIFyv92V91WI3KqiVlOvLtfoMRg=w300" />
</a>
</div>
'+'选择器的缺点是你悬停在'img'标签上方的元素,但是使用css可以移动该图标
相关文章:
- UIAutomation放大图像
- 如何在d3上的图形中添加放大和缩小按钮
- 如何使用javascript onmouseover缓慢放大图像
- 点击放大图片.JavaScript、CSS和HTML
- 鼠标悬停时如何居中放大背景图像
- 查找仅适用于原始图像的图像放大算法的名称
- addEventListener的Javascript代码不工作!?(单击时打开放大的img)
- 放大弹出生成“;找不到文件”;YouTube视频的错误
- 谷歌地图完全放大
- 使用angular缩放大图像以适应屏幕宽度
- 谷歌地图无法放大
- 当我使用JS/jQuery/any插件点击图像时,我如何使背景变暗+不可点击,并放大和居中我的图像
- 尝试制作youtube视频的缩略图,并在单击时将其放大
- 如何在拖动后获得图表的最小值和最大值放大高图表
- 使用 JavaScript 在我的 html 页面中放大图像
- 每个用户只显示一次放大弹出窗口
- 页面加载时加载放大弹出窗口
- 禁用“;保持按压”;以放大移动设备
- jQuery"悬停时放大”;无法相对于图片中心放大
- 放大位置数组