網站首頁 編程語言 正文
本文實例為大家分享了jquery實現邊框特效的具體代碼,供大家參考,具體內容如下
主要思想
1.將四個div分別定位到大div的上下左右位置
2.分別設置成寬度為0或者高度為0
3.讓其執行給定動畫,即多少毫秒讓寬度或者高度變為指定的長度
html代碼
<div class="box"> ? ? <div class="border_top"></div> ? ? <div class="border_bottom"></div> ? ? <div class="border_left"></div> ? ? <div class="border_right"></div> </div>
css代碼
.box{ ? ? ? ? width:234px; ? ? ? ? height:300px; ? ? ? ? position:relative; } .border_bottom,.border_left,.border_right,.border_top{ ? ? background: #ff6700; ? ? position: absolute; ? ? font-size: 0px; ? ? transition: all 0.5s ease-out; ? ? z-index: 99; } .border_bottom,.border_top{ ? ? height: 1px; ? ? width: 0px; } .border_right,.border_left{ ? ? height: 0px; ? ? width: 1px; } .border_top { ? ? top:0px; ? ? left:0px; } .border_right { ? ? top:0px; ? ? right:0px; } .border_bottom { ? ? right: 0px; ? ? bottom: 0px; } .border_left { ? ? left: 0px; ? ? bottom: 0px; }
js實現效果
1.引入jquery文件
<script src="jquery-1.8.3.min.js"></script>
2.jquery代碼
$('.main>li').hover(function(){ ? ? var index=$(this).index(); ? ? $(".border_top").stop(true,true); ? ? $(".border_left").stop(true,true); ? ? $(".border_bottom").stop(true,true); ? ? $(".border_right").stop(true,true); ? ? $(".border_top").eq(index).animate({width:"234px"},100) ? ? $(".border_left").eq(index).animate({height:"300px"},100) ? ? $(".border_bottom").eq(index).animate({width:"234px"},100) ? ? $(".border_right").eq(index).animate({height:"300px"},100) },function(){ ? ? var index=$(this).index(); ? ? $(".border_top").stop(true,true); ? ? $(".border_left").stop(true,true); ? ? $(".border_bottom").stop(true,true); ? ? $(".border_right").stop(true,true); ? ? $(".border_top").eq(index).animate({width:"0"},100) ? ? $(".border_left").eq(index).animate({height:"0"},100) ? ? $(".border_bottom").eq(index).animate({width:"0"},100) ? ? $(".border_right").eq(index).animate({height:"0"},100) });
原文鏈接:https://blog.csdn.net/m0_37805167/article/details/72236564
相關推薦
- 2023-11-13 linux tar指令壓縮解壓縮文件夾、文件命令詳解
- 2022-01-15 linux 安裝插件報錯:Loaded plugins: fastestmirror
- 2022-05-10 Element-ui 中 Select 選擇器下拉框樣式及輸入框樣式的修改問題(背景色透明與懸停背景
- 2022-05-12 Scss 遍歷之批量設置樣式
- 2022-11-16 創建Go工程化項目布局詳解_Golang
- 2024-03-16 Spring獲取Bean的方式
- 2022-06-28 C#操作Byte數組和十六進制進行互轉_C#教程
- 2022-05-18 C語言自定義類型超詳細梳理之結構體?枚舉?聯合體_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支