顶部的按钮不是并排? [英] Buttons on top of each other not side by side?

查看:124
本文介绍了顶部的按钮不是并排?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个按钮,我希望并排,但他们的权利在每个,我不能弄清楚为什么..这里是我正在看。

I have two buttons, that I was hoping to have side by side, however their right on top of each that I can't figure out why.. here's what i'm looking at.

这是我的代码。

CSS:

  button {
  position: absolute;  
  top: 250px;
   left: -15px; 
   z-index: 9999;
  color:white;
  display: block;
  margin: 30px;
  padding: 7px 35px;
  font: 300 150% langdon;
  background: transparent;
  border: 3px solid white;
  cursor: pointer;
  } 

  button:hover {
  background: black;
  border: 1px solid black;
  }

  button:active {
  background: #2e2e2e;
  border: 1px solid black;
  color: white;
  }

任何想法?

推荐答案

position:absolute 删除正常文档流中的元素。因此,它们将被定位在其中指定的( top:250px; left:-15px; )因为它们共享相同的位置样式。

position:absolute removes the elements from the normal document flow. Thus, they will be positioned on top of each other where specified (top: 250px;, left: -15px;) since they share the same position styles.

对于你的场景,最好使用浮动和边距:

For your scenario, it would probably be better to use floats and margins:

button {
    float:left;
    margin-top:250px;
}

这篇关于顶部的按钮不是并排?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆