The direction from which the modal layer enters and appears is determined by the mouse position.

Add-ons
2026-07-26 05:57 4 次浏览 • 0 次下载 1.9KB
The direction from which the modal layer enters and appears is determined by the mouse position.
### jQuery Plugin jquery.boxhovermodal.js

This plugin detects the direction from which the mouse enters a box when hovering over it, then makes the modal layer slide into the box from the corresponding top, bottom, left, or right direction.

#### HTML Section

A block with the class box-hover-modal contains an absolutely positioned inner block with the class box-hover-modal-m.

```html
<div class="box-hover-modal">
	<div class="box-hover-modal-con">Content</div>
	<div class="box-hover-modal-m">Overlay</div>
</div>
```

#### CSS Section

The outer block needs a position property. The inner block uses absolute positioning and is initially hidden.

```css
.box-hover-modal {
	position: relative;
	float: left;
	margin-right: 20px;
	margin-bottom: 20px;
	width: 200px;
	height: 200px;
	background: #aaa;
	overflow: hidden;
}
.box-hover-modal-con {
	width: 100%;
	height: 100%;
}
.box-hover-modal-m {
	display: none;
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	background: crimson;
}
```

### JAVASCRIPT Section

Developed using an encapsulated object approach, with one target object and one optional parameter.

```javascript
// The target object is .box-hover-modal. The optional parameter specifies the modal layer.
$(".box-hover-modal").boxhovermodal(".box-hover-modal-m");
```
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare