Tạo thanh menu liên hệ cố định bên phải cho website wordpress
Đầu tiên bạn chèn code vào file functions.php và nhớ đổi lại đường dẫn ảnh (icon)
function task_right(){ ?> <div id="sticky-nav"> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/edit.png"></span> <a href="#tongquan" class="info-expanded">Tổng quan</a> </div> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/location-2.png"></span> <a href="#vitri" class="info-expanded">Vị trí</a> </div> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/image.png"></span> <a href="#hinhanh" class="info-expanded">Hình ảnh</a> </div> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/home.png"></span> <a href="#maunha"class="info-expanded">Chọn mẫu nhà</a> </div> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/phone-call-3.png"></span> <a href="#lienhe" class="info-expanded">Liên hệ</a> </div> <div class="sticky-item"> <span class="icon-sticky"><img src="/wp-content/uploads/2021/05/top.png"></span> <a href="back-to-top" data-title="Lên đầu trang" role="button" class="info-expanded">Lên đầu trang</a> </div> </div> <?} add_action('wp_footer','task_right');
Sau đó chèn css vào file style.css của bạn
span img { width:unset} #sticky-nav { display: block; position: fixed; right: 0px; z-index: 997; top: 50%; transform: translateY(-50%); } #sticky-nav .sticky-item { background: #075E8E; overflow: hidden; border-bottom: 2px solid #075E8E; position: relative; display: block; width: 45px; margin: 0; outline-offset: -1px; -webkit-transition: width .6s ease-in-out; transition: width .6s ease-in-out; cursor: pointer; float: right; clear: both; } #sticky-nav .icon-sticky { vertical-align: middle; display: inline-block; text-align: center; width: 50px; } #sticky-nav .icon-sticky img { margin: 0 auto; width: 30px; height: 30px; margin: 10px; display: inline-block; } #sticky-nav .info-expanded { display: none; -webkit-transition: display .15s ease-in-out; transition: display .15s ease-in-out; color: #fff; font-size: 17px; } #sticky-nav .sticky-item:hover, #sticky-nav .sticky-item.active { width: 200px; background: #075E8E ; border-color: #075E8E ; } #sticky-nav .sticky-item:hover .info-expanded, #sticky-nav .sticky-item.active .info-expanded { display: block; position: absolute; width: 100%; height: 50px; top: 0px; line-height: 50px; padding-left: 50px; color: #fff; text-decoration: none; }