【发布时间】:2015-12-21 08:05:05
【问题描述】:
我的网站上有一个按钮,我使用了与分辨率无关的对齐方式。我检查了两个具有不同分辨率的不同计算机屏幕,它看起来还不错,但是,一旦在更大的纵横比屏幕或移动/平板设备上打开它就会重新定位。在宽高比较大的屏幕上,按钮向左移动,在较小的设备上,它向右浮动。我不是 100% 确定可能出了什么问题。下面是我的 CSS 和 HTML 代码。
HTML:
<div class="Welcome">
<h1>Welcome to Beauty Factory Bookings</h1>
<a href="website_link"><button>Book Appointment</button></a>
</div>
CSS:
body {
background: url('http://i.imgur.com/4mKmYMb.jpg') no-repeat fixed center center;
background-size: cover;
font-family: Montserrat;
margin: 0;
padding: 0;
.Welcome {
margin-top: 13%;
}
.Welcome h1 {
text-align: center;
font-family: Montserrat;
font-size: 50px;
text-transform: uppercase;
}
.Welcome button {
height: 60px;
width: 340px;
background: #ff656c;
border: 1px solid #e15960;
color: #fff;
font-weight: bold;
text-transform: uppercase;
font-size: 17px;
font-family: Montserrat;
outline: none;
cursor: pointer;
text-align: center;
margin-left: 33%;
margin-top: 3%;
border-radius: 5px;
}
知道如何解决这个问题吗?
【问题讨论】:
-
您确实需要创建一个MCVE。基本上,这意味着除非您无法使此处的按钮表现得像您网站上的按钮,否则我们将无法为您提供帮助。
-
只做我使用弹性盒子所做的事情。
-
我试过了,还是不行。您的解决方案可能非常好,我认为我的其余代码也有问题。
-
@Filip 在那里无论如何我可以看到你的网站我可以通过这种方式检查你的 src 文件.. 或者只是尝试将其上传到 codepen 或 GIThub