【发布时间】:2020-07-26 01:14:19
【问题描述】:
我有一个两行四列的结构,其中包含一个可变长度的字符串。启用自动行后,行可以拉伸以证明内容的合理性。我有一个按钮和每个网格的末端,我想将它们与网格的底部对齐。如果可以使用 css 网格轻松实现,有人可以帮助我吗?
html,
body {
padding: 0;
margin: 0;
}
input {
font-size: 14px;
font-family: Helvetica, sans-serif;
}
body {
background-color: #BBB;
font-family: Helvetica, sans-serif;
padding-bottom: 100px;
}
h2,
h3 {
margin: 0 0 .75em 0;
}
/* first example */
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-auto-rows: minmax(250px, auto);
}
.card {
border-right: 2px solid grey;
border-bottom: 2px solid grey;
padding: 1em;
}
.grid {
display: grid
}
<!-- first example -->
<div class="container">
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it.
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type.
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p class="grid"><button> Submit Me!</button></p>
</div>
<div class="card">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambledh the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p class="grid">
<button> Submit Me!</button>
</p>
</div>
</div>
这是 CodePen: https://codepen.io/awaisdar001/pen/wvKaEvx
【问题讨论】: