如何创建:固定的社交栏

学习如何使用 CSS 创建固定/粘性社交媒体图标栏。

亲自试一试

如何创建固定的社交栏

第一步 - 添加 HTML:

加载 Font Awesome 图标
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- စီးပွားရေး အက်အိုင်ဂီယို လက္ခဏာ စံပုံ -->
<div class="icon-bar">
  <a href="#" class="facebook"><i class="fa fa-facebook"></i></a>
  <a href="#" class="twitter"><i class="fa fa-twitter"></i></a>
  <a href="#" class="google"><i class="fa fa-google"></i></a>
  <a href="#" class="linkedin"><i class="fa fa-linkedin"></i></a>
  <a href="#" class="youtube"><i class="fa fa-youtube"></i></a>
</div>

ဒုတိယပွဲ - အခြေခံ CSS ထပ်ပေးပါ:

/* တိုက်ရိုက်/လက်ဆင်း အက်အိုင်ဂီယို လက္ခဏာ စံပုံ (အနောက်ဘက် ပြင် အမြင့် ၅၀% တွင် အပြင်းအထန် တည်ရှိ) */
.icon-bar {
  position: fixed;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}
/* အက်အိုင်ဂီယို အက်အိုင်ဂီယို လက္ခဏာ အမျိုးအစား စံပုံ ကို အသုံးပြုပါ */
.icon-bar a {
  display: block;
  text-align: center;
  padding: 16px;
  transition: all 0.3s ease;
  color: ဝေါက်ရောင်;
  font-size: 20px;
}
/* လိုချင်လျှင် စီးပွားရေးဝီကီ အက်အိုင်ဂီယို အမျိုးအစား အရေးအသား စံပုံ ကို အသုံးပြုပါ */
.icon-bar a:hover {
  background-color: #000;
}
.facebook {
  background: #3B5998;
  color: ဝေါက်ရောင်;
}
.twitter {
  background: #55ACEE;
  color: ဝေါက်ရောင်;
}
.google {
  background: #dd4b39;
  color: ဝေါက်ရောင်;
}
.linkedin {
  background: #007bb5;
  color: ဝေါက်ရောင်;
}
.youtube {
  background: #bb0000;
  color: ဝေါက်ရောင်;
}

亲自试一试

相关页面

教程:CSS 定位