高度固定且多行文本的按钮不显示在相同的垂直位置

button fixed in height with text in multiple rows do not show in same vertical position

按钮 css 固定高度使垂直位置难看,因为每个按钮文本都超过一行

我试着评论 height:80px; 然后所有的按钮都在顶部垂直对齐,但是所有的按钮都会有不同的高度,带上 BUTTONS GROUP看起来很难看,尤其是我需要生成10多个按钮

button {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: normal;
  color: #444;
  width: 120px;
  height:80px !important;
  display:inline-block;
  padding:5px;
  margin: 5px 10px;
  background-color: #fdfdfd;
  border: 1px solid #cdcdcd;
  cursor: pointer;
  border-radius: 3px;
  word-wrap: break-word;
}
<button>Text in one row </button>
<button>Text in more than one row in this button </button>
<button>Text in more than two rows in this button which have same height </button>
<button>Text in more than three rows in this button which have same height, but more text </button>

CLICK to open an image

jsfiddle

如何让按钮的高度固定并且所有按钮都垂直放置在顶部。 注意:每个按钮的字数不同,自动换行为1行、2行、3行...

如果您将 vertical-align: top; 添加到 button 元素,这将解决您的问题

CSS

button {
   font-family: Arial, Helvetica, sans-serif;
   font-weight: normal;
   color: #444;
   width: 120px;
   height: 80px;
   display: inline-block;
   padding: 5px;
   margin: 5px 10px;
   background-color: #fdfdfd;
   border: 1px solid #cdcdcd;
   cursor: pointer;
   border-radius: 3px;
   word-wrap: break-word;
   vertical-align: top;
}

运行下面的代码片段看结果

button {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: normal;
  color: #444;
  width: 120px;
  height: 80px;
  display: inline-block;
  padding:5px;
  margin: 5px 10px;
  background-color: #fdfdfd;
  border: 1px solid #cdcdcd;
  cursor: pointer;
  border-radius: 3px;
  word-wrap: break-word;
  vertical-align: top;
}
<button>Text in one row </button>
<button>Text in more than one row in this button </button>
<button>Text in more than two rows in this button which have same height </button>
<button>Text in more than three rows in this button which have same height, but more text </button>