前军教程网

中小站长与DIV+CSS网页布局开发技术人员的首选CSS学习平台

49-图标特效

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>49-图标特效</title>

<style type="text/css">

*{

margin: 0; /*外边距:0*/

padding: 0; /*内边距:0*/

}

ul{

list-style: none; /*去除前面的点*/

width: 400px; /*宽:400*/

height: 250px; /*高:250*/

border: #000000 solid 1px; /*边框:黑色 实线 1像素*/

margin: 100px auto; /*外边距:上100像素 左右自动居中*/

}

ul>li{

width: 100px; /*宽:100*/

height: 50px; /*高:50*/

margin-top: 50px; /*上边距:50*/

text-align: center; /*元素中的文本排列到中间*/

float: left; /*浮动:左浮动*/

}

ul>li>span{

display: inline-block; /*允许在元素上设置宽度和高度*/

width: 50px; /*宽:50*/

height: 50px; /*高:50*/

overflow: hidden; /*元素的内容若超出了给定的宽度和高度属性,那么超出的部分将会被隐藏*/

/* top: -50px; */

}

ul>li>span>img{

position: relative; /*定位:相对定位*/

}

</style>

<script src="../static/js/jquery-3.6.0.js"></script>

<script type="text/javascript">

$(function(){

$('li').mouseenter(function(){ //li标签的鼠标移入事件

$(this).children('span').children('img').animate({top:-50}, 1000, function(){ //找到这个li标签的孩子span的孩子img添加自定义动画:用1秒的时间上边距调到-50,之后调用:

$(this).css('top','50px') // 当前对象的css样式中的top值设置成50px

$(this).animate({top:0},1000) // 为当前对象添加自定义动画:1秒时间top移到0

})

})

})

</script>

</head>

<body>

<ul>

<li><span><img src="../static/image/jQuery.ico" ></span><p>jQuery</p></li>

<li><span><img src="../static/image/大鱼号.ico" ></span><p>大鱼号</p></li>

<li><span><img src="../static/image/头条.png" width="32px" height="32px" ></span><p>头条</p></li>

<li><span><img src="../static/image/开课吧.ico" width="32px" height="32px"></span><p>开课吧</p></li>

<li><span><img src="../static/image/微信.ico" ></span><p>微信</p></li>

<li><span><img src="../static/image/新浪.ico" ></span><p>新浪</p></li>

<li><span><img src="../static/image/树莓派.ico" ></span><p>树莓派</p></li>

<li><span><img src="../static/image/百度.ico" width="32px" height="32px" ></span><p>百度</p></li>

</ul>

</body>

</html>

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言