我在一个长度为4+的div中有一系列文章,没有任何舍入行标记.我需要将它表示为每行3篇文章(列)的表,可能有display: grid.每篇文章都有一个标题,一个部分和一个页脚.
如何为每个标题实现相同的高度,每个部分的高度相等,以及与文章底部对齐的相等高度的页脚,在每行文章中?它甚至可能吗?我应该用display: table吗?
PS我需要动态地改变每行的文章数量,具体取决于屏幕宽度.感谢名单.
HTML:
body {
width: 100%;
max-width: 1024px;
margin: auto;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.container article {
display: grid;
}
article header {
background-color: #eeeeee;
}
article section {
background-color: #cccccc;
}
article footer {
background-color: #dddddd;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<article>
<header>
<h2>Header</h2>
<h2>Header</h2>
</header>
<section>
<p>Content</p>
</section>
<footer>
<p>Footer</p>
</footer>
</article>
<article>
<header>
<h2>Header</h2>
</header>
<section>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</section>
<footer>
<p>Footer</p>
<p>Footer</p>
</footer> …Run Code Online (Sandbox Code Playgroud)我想实现通用和类型安全的域存储库。说我有
trait Repo[Value] {
def put(value: Value): Unit
}
case class IntRepo extends Repo[Int] {
override def put(value: Int): Unit = ???
}
case class StringRepo extends Repo[String] {
override def put(value: String): Unit = ???
}
case class DomainRepo(intRepo: IntRepo, stringRepo: StringRepo) {
def putAll[?](values: ?*): Unit // what type should be here?
}
Run Code Online (Sandbox Code Playgroud)
结果,我想要以下api:
domainRepo.putAll(1, 2, 3, "foo", "bar") //Should work
domainRepo.putAll(1, 2, true, "foo") // should not compile because of boolean value
Run Code Online (Sandbox Code Playgroud)
问题是如何实现这一目标?
因此,我只看到一种使其成为类型安全的方法。可以对任何类型的样式进行匹配
def putAll(values: Seq[Any]) …Run Code Online (Sandbox Code Playgroud)