在我的頁面底部,我使用了一個帶有Font Awesome圖標的滾動頂部按鈕。向上箭頭具有帶邊框的背景顏色:50%和懸停顏色。我已經搜遍了,並且邊界50%應該做一個圓形,但是在這種情況下有些東西阻止了它。我想在圖標上添加一個簡單的圓形背景顏色。圓形上的Font Awesome在Bootstrap 4上去頂部按鈕
我的代碼
#Scroll {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: #5F9EA0;
color: white;
text-align:center;
cursor: pointer;
padding: 15x;
border-radius: 50%;
opacity: .6;
}
#Scroll:hover {
color: #004289;
background-color: #FFE466;
}
<button onclick="topFunction()" id="Scroll" title="Go to top"><i class="fa fa-2x fa-arrow-circle-up"></i></button>
<script>
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("Scroll").style.display = "block";
} else {
document.getElementById("Scroll").style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
'border-radius:50%'不會奇蹟般地形成一個圓,而是一個橢圓。您必須確保元素具有相同的高度和寬度。 – Blazemonger