html - 如何将按钮右对齐?

标签 html css

下午好, 我意识到这个话题已经被问过好几次,并且有几个解决方案,正如我在搜索你们的论坛时看到的那样。

但是解决方案,例如, <input type="button" value="Click Me" **style="float: right;"**> ,

即使按钮成功地向右对齐,它们也会与我的页脚重叠,因为按钮应该位于页脚的正上方。这是我的代码:

.button {
  border-radius: 4px;
  background-color: #0FA0FF;
  border: none;
  color: #FFFFFF;
  text-align: center;
  font-size: 15px;
  padding: 10px;
  width: 200px;
  transition: all 0.5s;
  cursor: pointer;
  margin: 5px;
}
.button span {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: 0.5s;
}
.button span:after {
  content: '\00bb';
  position: absolute;
  opacity: 0;
  top: 0;
  right: -20px;
  transition: 0.5s;
}
.button:hover span {
  padding-right: 25px;
}
.button:hover span:after {
  opacity: 1;
  right: 0;
}
.containers-fluid {
  padding: 20px 50px;
  background-color: #000000;
  color: white;
}
<button class="button"><span>Proceed to Next Lesson </span>
</button>

<footer class="containers-fluid text-center">
</footer>

最佳答案

只需将样式 float:right 添加到您的 button

buttonfooter 之间添加这个

<div class="clearfix"></div>

clearfix 的 css

.clearfix{
 clear: both;
}

阅读更多关于 clearfix 的信息

.button {
  border-radius: 4px;
  background-color: #0FA0FF;
  border: none;
  color: #FFFFFF;
  text-align: center;
  font-size: 15px;
  padding: 10px;
  width: 200px;
  transition: all 0.5s;
  cursor: pointer;
  margin: 5px;
  float: right;
  display: block;
}
.button span {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: 0.5s;
}
.button span:after {
  content: '\00bb';
  position: absolute;
  opacity: 0;
  top: 0;
  right: -20px;
  transition: 0.5s;
}
.button:hover span {
  padding-right: 25px;
}
.button:hover span:after {
  opacity: 1;
  right: 0;
}
.containers-fluid {
  padding: 20px 50px;
  background-color: #000000;
  color: white;
}
.clearfix{
 clear: both;
}
<button class="button"><span>Proceed to Next Lesson </span>
</button>
<div class="clearfix"></div>
<footer class="containers-fluid text-center">
</footer>

关于html - 如何将按钮右对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41407840/

相关文章:

javascript - 将 div 中的多个跨度之一水平居中

javascript - Bootstrap 菜单消失 onclick onmobile/& header image 不会调整大小

jquery 元素在 ios 上过渡和滚动后闪烁

html - 如何阻止 Safari 使用错误的电子邮件自动填充电子邮件字段?

javascript - 使用表单值 javascript

html - li 元素在 sibling 有不同数量的文本行时下推

html - 如何将 flex column child 设置为可用高度?

html - 如何在图像上显示复选框以供选择?

filter - 通过 CSS3(过滤器)更改图像颜色

Javascript隐藏DIV