cid1020 HTML CSS & JQuery 制作社交媒体分享按钮

index.html

  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <link rel="stylesheet" href="style.css">
  7. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  9. </head>
  10. <div class="middle">
  11. <div class="sm-container">
  12. <i class="show-btn fas fa-user"></i>
  13. <div class="sm-menu">
  14. <a href="#"><i class="fab fa-facebook-f"></i></a>
  15. <a href="#"><i class="fab fa-twitter"></i></a>
  16. <a href="#"><i class="fab fa-instagram"></i></a>
  17. <a href="#"><i class="fab fa-youtube"></i></a>
  18. <a href="#"><i class="fab fa-whatsapp"></i></a>
  19. </div>
  20. </div>
  21. </div>
  22. <script>
  23. $(".show-btn").click(function(){
  24. $(".sm-menu").fadeToggle("fast");
  25. });
  26. </script>
  27. </body>
  28. </html>
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  </head>


    <div class="middle">
      <div class="sm-container">
        <i class="show-btn fas fa-user"></i>
        <div class="sm-menu">
          <a href="#"><i class="fab fa-facebook-f"></i></a>
          <a href="#"><i class="fab fa-twitter"></i></a>
          <a href="#"><i class="fab fa-instagram"></i></a>
          <a href="#"><i class="fab fa-youtube"></i></a>
          <a href="#"><i class="fab fa-whatsapp"></i></a>
        </div>
      </div>
    </div>


    <script>
      $(".show-btn").click(function(){
        $(".sm-menu").fadeToggle("fast");
      });
    </script>
  </body>
</html>

 

style.css

  1. body{
  2. margin: 0;
  3. padding: 0;
  4. background: #9c88ff;
  5. }
  6. .middle{
  7. position: absolute;
  8. top: 50%;
  9. left: 50%;
  10. transform: translate(-50%,-50%);
  11. }
  12. .sm-container{
  13. text-align: center;
  14. }
  15. .sm-container i{
  16. color: #f5f6fa;
  17. padding: 20px;
  18. font-size: 20px;
  19. cursor: pointer;
  20. transition: 0.4s;
  21. }
  22. .sm-container i:hover{
  23. transform: scale(1.2);
  24. }
  25. .sm-menu{
  26. background: #487eb0;
  27. position: absolute;
  28. border-radius: 8px;
  29. display: none;
  30. }
  31. .sm-menu::before{
  32. content: "";
  33. width: 10px;
  34. height: 10px;
  35. background: #487eb0;
  36. position: absolute;
  37. top: -5px;
  38. left: 50%;
  39. transform: translateX(-50%) rotate(45deg);
  40. }
body{
  margin: 0;
  padding: 0;
  background: #9c88ff;
}

.middle{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

.sm-container{
  text-align: center;
}

.sm-container i{
  color: #f5f6fa;
  padding: 20px;
  font-size: 20px;
  cursor: pointer;
  transition: 0.4s;
}

.sm-container i:hover{
  transform: scale(1.2);
}

.sm-menu{
  background: #487eb0;
  position: absolute;
  border-radius: 8px;
  display: none;
}

.sm-menu::before{
  content: "";
  width: 10px;
  height: 10px;
  background: #487eb0;
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}

 

 

 

让链接同时具备两种打开方式
获取源码: Sm Buttons
下载数:28人次, 文件大小: 1.1 KB, 上传日期: 2020年-11 月-26日

公众号回复:gcode  获取解压密码

qrcode_for_gh_6ea2c28a1709_258 (1)

1,607 人查阅

类似文章