Skip to main content

Tạo nút Back To Top cho Blog

Hôm nay là ngày chủ nhật, vào ghé thăm cái blog mới làm. Nhìn ngang ngó dọc vẫn thấy nó thiếu thiếu một cái gì đó. Đang lúc ăn cơm, chợt nghĩ đến cái Back To Top mà mình đã áp dụng cho mấy cái Blog kia, nên bây giờ áp dụng vào blog, tiện thể share luôn. Demo các bạn xem trên blog của mình.


  •  Như thường lệ, ta vào Mẫu >> Chỉnh sửa HTML
  • Thêm đoạn code sau vào trước thẻ </body> (Để vào sau <head> cũng được nhưng nên để code cuối trang vì ta sẽ để load sau cùng):

<style type='text/css'>

#bttop{border:1px solid #4adcff;background:#24bde2;text-align:center;padding:5px;position:fixed;bottom:35px;right:10px;cursor:pointer;display:none;color:#fff;font-size:11px;font-weight:900;line-height: 25px;}

#bttop:hover{border:1px solid #32cd32;background:#bada55;}

</style>

<div id='bttop'>BACK TO TOP</div>

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'></script>

<script type='text/javascript'>$(function(){$(window).scroll(function(){if($(this).scrollTop()!=0){$('#bttop').fadeIn();}else{$('#bttop').fadeOut();}});$('#bttop').click(function(){$('body,html').animate({scrollTop:0},800);});});</script>

Ghi chú:
Ở giữa 2 thẻ <style type='text/css'> và </style> là đoạn css định hình dạng cho nút Back to Top, các bạn tùy chỉnh thoải mái.
Dòng code màu lam là thư viện Jquery, nếu có rồi thì các bạn nên xóa nó đi.
BACK TO TOP các bạn thay bằng gì cũng được (GO TOP chẳng hạn).

Chúc thành công!

Comments

  1. Nếu muốn thẩm mỹ hơn , thay bằng hình ảnh cũng dc (h)

    ReplyDelete
    Replies
    1. (o) lúc đầu em định dùng ảnh nhưng thấy cái này khá đẹp nên giữ lại dùng. Bác cũng áp dụng đi :>)

      Delete
  2. làm sao tạo nút quay lại trang trước ak

    ReplyDelete

Post a Comment

Popular posts from this blog

Leveraging the Fast TikTok API on Apify for Efficient Data Scraping

Introduction: In the world of social media data analysis, TikTok has emerged as a popular platform with a vast amount of user-generated content. To extract valuable insights from TikTok, developers and researchers often resort to web scraping. One efficient way to accomplish this task is by utilizing the Fast TikTok API on the Apify platform. In this article, we will explore the benefits and capabilities of leveraging the Fast TikTok API for data scraping on TikTok. Check the API here:  https://apify.com/novi/fast-tiktok-api

Giải trí với video hài

Hy vọng video này sẽ giúp mọi người thư giãn và xả xì trét :D

Tutorial: Scraping Data from TikTok using Fast TikTok API with Python

In this tutorial, I will guide you through the process of scraping data from TikTok using the Fast TikTok API with Python. We will be using the requests library to make HTTP requests and retrieve data from the API. Let's get started! Step 1: Obtain API Credentials Go to https://apify.com and create an account if you haven't already. Once logged in, navigate to the Fast TikTok API page ( https://apify.com/novi/fast-tiktok-api ). Follow the instructions on the page to obtain your API credentials, such as an API key or access token. Make sure to note down these credentials for future use. Step 2: Set up your Python Environment Ensure that you have Python installed on your system. You can download the latest version of Python from the official website ( https://www.python.org ). Install the requests library by running the following command in your terminal: pip install requests Step 3: Import Required Libraries Open your preferred Python IDE or text editor and create a new Python