<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.message{
position: fixed;
top: -50px;
left: 50%;
width: 100px;
height: 50px;
text-align: center;
line-height: 50px;
background-color: #00aaee;
color: #fff;
box-sizing: border-box;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="message">hello</div>
<button id="btn">btn</button>
</body>
</html>
<script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
function fade(text){
$('.message').html(text);
//.css无动画过渡效果
// $('.message').css({
// top: "50px",
// })
// setTimeout(() => {
// $('.message').css({
// top: "0"
// })
// },2000)
// .animate有动画过渡效果
$('.message').animate({
top: "50px"
})
setTimeout(() => {
$('.message').animate({
top: "-50px"
})
},2000)
}
$('#btn').click(() => {
fade("hello")
})
</script>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。