简体   繁体   English

在div中将顶部的元素水平对齐

[英]horizontally align elements inside div at the top part

I would like to align these elements horizontally: 我想将这些元素水平对齐:

<div class="row">
  <div class="block">xxxxx</div>
  <div class="block">xxxx</div>
  <div class="block">xxx</div>
  <div class="block"><select multiple></select>
</div>

.row {
  width: 100%;
  /*margin: 0 auto;*/
    text-align: center;
}
.block {
  width: 100px;
  /*float: left;*/
    display: inline-block;
    zoom: 1;
}

However the output that I see with the previous code is that: 但是我在前面的代码中看到的输出是:

               divS
               divS
div1 div2 div3 divS

I want to find a way to align the first three divs with the top part of the select and not with the bottom part. 我想找到一种方法,使前三个div与select的顶部对齐而不是与底部对齐。

div1 div2 div3 divS
               divS
               divS

Is it possible? 可能吗?

Add vertical-align:top to .block class. vertical-align:top添加到.block类。 Please let me know if you wanted this. 如果您要这个,请告诉我。

.block {
  width: 100px;
  /*float: left;*/
    display: inline-block;
    zoom: 1;
    vertical-align:top;
}
.row {
  width: 100%;
  /*margin: 0 auto;*/
    text-align: center;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM