CSS3感知鼠标进入方向

快乐打工仔 分类:实例代码

CSS3感知鼠标进入方向属于前端实例代码,有关更多实例代码大家可以查看

以前实现鼠标进入方位的感知功能,需要结合javascript来实现。

css3的普遍应用又提供了一个新的方式。

代码实例如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>犀牛前端部落</title>
<style type="text/css">
.antzone {
width: 1000px;
height: auto;
overflow: hidden;
cursor: pointer;
}
.antzone [fox=con] {
width: calc((990px - 10px * 3) / 4);
background: url(demo/CSS/img/shangpin.jpg) -616px 0 no-repeat;
height: calc((990px - 10px * 3) / 4 / 3 * 4);
position: relative;
overflow: hidden;
margin: 10px 10px 0 0;
float: left;
}
.antzone [fox=con] [fox$=_c]:nth-of-type(2n-1) {
width: 240px;
height: 240px;
transform: rotate(45deg) skew(8deg,8deg);
position: absolute;
left: 2px;
}
.antzone [fox=con] [fox$=_c]:nth-of-type(2n) {
width: 240px;
height: 240px;
transform: rotate(45deg) skew(8deg,8deg);
position: absolute;
top: 42px;
}
.antzone [fox^=top] {
top: -151px;
}
.antzone [fox^=right] {
left: 148px;
}
.antzone [fox^=bottom] {
bottom: -151px;
}
.antzone [fox^=left] {
right: 147px;
}
.antzone [fox=con]:hover [fox$=_c] {
transform: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.antzone [fox=con] [fox$=_c]:hover {
z-index: 5;
}
.antzone [fox$=_c] [fox$=_con] {
display: block;
width: calc((990px - 10px * 3) / 4);
height: calc((990px - 10px * 3) / 4 / 3 * 4);
background-image: linear-gradient(0deg,#4fc4b2,#fff,#b0fef2);
}
.antzone [fox^=top] [fox$=_con] {
transform: translateY(-100%);
}
.antzone [fox^=bottom] [fox$=_con] {
transform: translateY(100%);
}
.antzone [fox^=left] [fox$=_con] {
transform: translateX(-100%);
}
.antzone [fox^=right] [fox$=_con] {
transform: translateX(100%);
}
.antzone [fox$=_c]:hover [fox$=_con] {
transform: translateY(0);
transition: all .3s linear;
transform: translateX(0);
}
</style>
</head>
<body>
<div>
<div style="width:990px;margin:0 auto;">
<div class="antzone">
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
<div fox="con">
<div fox="top_c"><a fox="con_con"></a></div>
<div fox="right_c"><a fox="con_con"></a></div>
<div fox="bottom_c"><a fox="con_con"></a></div>
<div fox="left_c"><a fox="con_con"></a></div>
</div>
</div>
</div>
</div>
</body>
</html>

CSS3感知鼠标进入方向,这样的场景在实际项目中还是用的比较多的,关于CSS3感知鼠标进入方向就介绍到这了。

回复

我来回复
  • 暂无回复内容