我需要有6个相对位置的div作为可点击按钮,3个向上和3个向下具有特定文本。问题是 - 当我写2或3个长字(它们需要很长的宽度)时,一些按钮会上升或下降。我知道这是" display:inline-block"的问题。
HTML
<div class="Box_parent">
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div></a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div></a>
<a><div id="Box_button"> <div class="box_text"> REALLY REALLY REALLY LONG TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> REALLY REALLY REALLY LONG TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div> </a>
</div>
CSS
#Box_button{
height:300px;
width:300px;
background-color:#4286f4;
margin:15px 15px;
display: inline-block;
}
.box_text{
font-family:Arial;
color:white;
font-size:30px;
}
.Box_parent{
position:relative;
text-align:center;
max-width:1300px;
margin:auto;
margin-top:130px;
vertical-align: bottom;
}
答案 0 :(得分:2)
将vertical-align添加到内联块的元素。
#Box_button{
height:300px;
width:300px;
background-color:#4286f4;
margin:15px 15px;
display: inline-block;
vertical-align: middle;
}
在旁注中,id在页面上应该是唯一的。您可能希望将box_button更改为类。