網(wǎng)站首頁 編程語言 正文
本文實例為大家分享了jquery實現(xiàn)邊框特效的具體代碼,供大家參考,具體內(nèi)容如下
主要思想
1.將四個div分別定位到大div的上下左右位置
2.分別設(shè)置成寬度為0或者高度為0
3.讓其執(zhí)行給定動畫,即多少毫秒讓寬度或者高度變?yōu)橹付ǖ拈L度
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實現(xiàn)效果
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
相關(guān)推薦
- 2022-07-31 C++超詳細(xì)分析講解內(nèi)聯(lián)函數(shù)_C 語言
- 2021-12-05 Linux系統(tǒng)運(yùn)行級別詳細(xì)介紹_Linux
- 2022-10-18 Python?numpy下幾種fft函數(shù)的使用方式_python
- 2022-11-20 CPython?垃圾收集器檢測循環(huán)引用詳解_python
- 2022-10-25 一文搞懂Golang中iota的用法和原理_Golang
- 2022-07-30 注冊中心eureka的介紹及源碼探索
- 2022-09-25 git問題:“ unable to auto-detect email address”或 “***
- 2022-05-22 Redis高可用集群redis-cluster詳解_Redis
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支