有没有一种方法可以使用display:fixed;使元素始终可见?

时间:2019-01-04 05:23:28

标签: html css wordpress

我对HTML相当陌生,我正在一家人的网站上工作,他们想要一个位于右上角的按钮。

该按钮可以正常使用并且位于正确的位置,问题在于仅当您首先向下滚动页面一半然后它会停留时,它才会出现。 如何使它始终可见而无需先向下滚动

它在Wordpress中,因此我被困在页面中间或页脚中的窗口小部件位置

<style>
   #button {
     position: fixed;
     background-image: url(buttonimg.png);
     width: 125px;
     height: 125px;
     background-size: cover;
     border-radius: 100px;
     border: none;
     top: 90px;
     right: 0px;
     z-index: 3
   }

   font {
     line-height: 28px;
     color: black;
   }
</style>

<a href="example.com">
   <button type="button" id="button">
       <font size="4" spacing="0">
          Press this button
       </font>
   </button>
</a>

2 个答案:

答案 0 :(得分:0)

将top:90px更改为top:0。这会将按钮放在页面顶部。

答案 1 :(得分:-2)

我不明白您的确切要求。如果要将按钮放在顶部位置,可以将这种样式设置为按钮ID:

top: 0;
right: 0;

它看起来像这样:

enter image description here

相关问题