【发布时间】:2018-01-03 00:42:21
【问题描述】:
有谁知道我怎样才能使这两个按钮居中,以便无论用户屏幕的大小如何,它们都保持在页面的中心底部?
<a class="my-button" title="Relevant Title" href="#">Back</a><a class="my-
button" title="Relevant Title" href="#">Next</a>
.my-button {
display: inline-block;
margin: 5px;
background: #32CE87;
color: white;
font-size: 1.5em;
font-family: 'Raleway', sans-serif;
text-align: center;
border-radius: 5px;
padding: 8px 16px;
-moz-transition: all 0.2s;
-webkit-transition: all 0.2s;
transition: all 0.2s;
left:30rem;
right:10rem;
position: relative;
top:-4rem;
width: 100px;
text-decoration: none;
}
.my-button:hover {
background: #666;
color: #c1e1e0;
}
【问题讨论】:
-
text-align: center在这两个锚标记的包含元素上将足以水平居中,不需要right和left属性值 - 除非您尝试对齐 绝对定位元素。考虑编辑您的问题以添加更多上下文并使您的意图更加清晰。 -
感谢 UncaughTypeError,我现在已经成功排序了 :)