我有一个背景图像,我试图把按钮放在中间底部的某个地方。但当我将浏览器移动到屏幕的左侧或一侧时,按钮会稍微移动。但我想让它保持在原来的位置。谁能告诉我我哪里做错了?下面是我的CSS。
body
{
margin:0;
padding :0;
background:url(ht.JPG);
background-attachment: fixed;
background-position: 50% 50%;
background-size:cover;
background-repeat: no-repeat;
font-family:sans-serif;
}
#loginbutton
{
font-weight: bold;
font-size:18px;
opacity:0.6;
align-items: center;
text-align:center;
border:none;
height:100px;
width:100px;
border-radius: 50%;
background:transparent;
color:black;
background-color:#EAEAEA;
position: absolute;
top:69%;
left:45%;
}
下面是我在html上的按钮。
<a href="register.html" ><button type="submit" value="Submit" id="loginbutton">Login</button></a>
发布于 2018-05-30 10:10:52
我尝试将背景图像拟合到窗口高度:
[https://jsfiddle.net/n09sos3c/3/][1]
请注意,在非常小的窗口分辨率下,这并不能确保按钮仍然不适合正确的位置,因为图像会缩小,但按钮不会。
你可以在这里了解背景速记:https://css-tricks.com/almanac/properties/b/background/
https://stackoverflow.com/questions/50595245
复制相似问题