
要实现的点赞功能比较简单,就是实现点击按钮,有心向上飘,一直飘出屏幕外。
首先只需要在body中定义一个button。和盛放心的盒子
<p id = "demo"></p> <input type = "button" id = "btn1" value = "点个赞吧" />
由于还要引进心的图片,所以在这里我们在设置css样式的时候还要设置图片img的样式。
css代码如下:
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
#btn1{
position: absolute;
bottom:100px;
width: 200px;
background-color: lightblue;
font-size: 18px;
left:45%;
}
img{
bottom:100px;
margin-left: -15px;
width: 20px;
height:20px;
position: absolute;
left: 50%;
}
</style>下来就是要写jquery函数。
效果图如下:


相关推荐:
利用Canvas实现直播时点赞冒气泡的效果
使用JavaScript实现评论点赞功能
jquery心形点赞关注效果的简单实现
