Bài viết này mình sẽ giới thiệu đến các bạn đoạn CSS, HTML và JAVASCRIPT tạo hiệu ứng tuyết rơi tuyệt đẹp và ông già noel di chuyển trên blogspot. Code cũng không ảnh hưởng mấy tới tốc độ của blog nên các bạn không cần quan tâm về nó.
Demo các bạn có thể xem ở blog của mình.
Tạo hiệu ứng tuyết rơi và ông già Noel di chuyển trên blogspot

CÁC BƯỚC THỰC HIỆN:

Bước 1: Truy cập vào trang chỉnh sửa HTML của Blogspot.
Bước 2: Dán 2 đoạn code phía dưới và trước thẻ </body>

Code hiệu ứng tuyết rơi:

<style type="text/css">
.snow-container { position:fixed; width:100%; max-width:100%; z-index:99999; pointer-events:none; overflow:hidden; top:0; height:100% }
.snow { display:block; position:absolute; z-index:2; top:0; right:0; bottom:0; left:0; pointer-events:none; -webkit-transform:translate3d(0,-100%,0); transform:translate3d(0,-100%,0); -webkit-animation:snow linear infinite; animation:snow linear infinite }
.snow.foreground { background-image:url("https://2.bp.blogspot.com/-Wy6UPSscdjQ/WiaUVdMxwvI/AAAAAAAAAUU/VlYKpmYGGGskfkn9gc9yKYx-TNKArubPACLcBGAs/s1600/snow-effect-_---------BacSiWindows-Com.png "); -webkit-animation-duration:15s; animation-duration:10s }
.snow.foreground.layered { -webkit-animation-delay:7.5s; animation-delay:7.5s }
.snow.middleground { background-image:url(https://dl6rt3mwcjzxg.cloudfront.net/assets/snow/snow-medium-0b8a5e0732315b68e1f54185be7a1ad9.png); -webkit-animation-duration:20s; animation-duration:15s }
.snow.middleground.layered { -webkit-animation-delay:10s; animation-delay:10s }
.snow.background { background-image:url(https://2.bp.blogspot.com/-cZWwrfEYtMI/WiaUgSmqv6I/AAAAAAAAAUY/fayIXcjKnvoWtHL-x-2H2oO5-Ks2e6_nQCLcBGAs/s1600/snow-effect_-_--------------BacSiWindows-Com.png); -webkit-animation-duration:25s; animation-duration:20s }
.snow.background.layered { -webkit-animation-delay:12.5s; animation-delay:12.5s }
@-webkit-keyframes snow {
    0% { -webkit-transform:translate3d(0,-100%,0); transform:translate3d(0,-100%,0) } 100% { -webkit-transform:translate3d(5%,100%,0); transform:translate3d(5%,100%,0) }
}
@keyframes snow {
    0% { -webkit-transform:translate3d(0,-100%,0); transform:translate3d(0,-100%,0) } 100% { -webkit-transform:translate3d(5%,100%,0); transform:translate3d(5%,100%,0) }
}
</style>
<div class='snow-container'><div class='snow foreground'/><div class='snow foreground layered'/><div class='snow middleground'/><div class='snow middleground layered'/><div class='snow background'/><div class='snow background layered'/></div>

Code ông già Noel di chuyển:

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'type='text/javascript'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){$('html').append('<img id="halo" title="Happy Noel" style="cursor:pointer; position:fixed; z-index:99999" height="120" src="https://lh3.ggpht.com/-LSDhJFNSG-E/VnQh0rSGAHI/AAAAAAAADoo/3FdK8o-hZ6A/s1600/tuan_loc_cho_qua_cua_ong_gia_noel_anh.gif"/>')
setInterval(function(){var $X=Math.ceil(Math.random()*$(window).width())
var $Y=Math.ceil(Math.random()*$(window).height())
$('img#halo').animate( { 'left':$X,'top':$Y }
,5000)}
,5000)
$('img#halo').click(function() { window.open('https://lh3.ggpht.com/-LSDhJFNSG-E/VnQh0rSGAHI/AAAAAAAADoo/3FdK8o-hZ6A/s1600/tuan_loc_cho_qua_cua_ong_gia_noel_anh.gif','') }
)}
)
//]]>
</script>
Lưu ý: Nếu blog của các bạn có thư viện jquery rồi thì các bạn xóa đoạn <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'type='text/javascript'></script>trong code 2 đi
Chúc các bạn thành công!
Nguồn: Bác Sỉ Window và dinhboblog
- - 0 bình luận
CHUYÊN MỤC

HIỆN TẠI CÓ 0 BÌNH LUẬN

Một số lưu ý khi bình luận

Mọi bình luận sai nội quy sẽ bị xóa mà không cần báo trước (xem nội quy)

Bấm Thông báo cho tôi bên dưới khung bình luận để nhận thông báo khi admin trả lời

Để bình luận một đoạn code, hãy mã hóa code trước nhé