It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center 。
7年前关闭。
我需要在屏幕底部放置一个按钮。我需要使用相对尺寸而不是绝对尺寸,所以它适合任何屏幕尺寸。
我的 CSS 代码:
既然你想在 相对定位 做,你应该去
EDIT1: JSFiddle1
EDIT2: 要将按钮放置在屏幕中央,
JSFiddle2
7年前关闭。
我需要在屏幕底部放置一个按钮。我需要使用相对尺寸而不是绝对尺寸,所以它适合任何屏幕尺寸。
我的 CSS 代码:
position:relative;
left:20%;
right:20%;
bottom:5%;
top:60%;
最佳答案
下面的 css 代码始终将按钮保留在页面底部
position:absolute;
bottom:0;
既然你想在 相对定位 做,你应该去
margin-top:100%
position:relative;
margin-top:100%;
EDIT1: JSFiddle1
EDIT2: 要将按钮放置在屏幕中央,
position:relative;
left: 50%;
margin-top:50%;
JSFiddle2