css - 如何将帖子标题放在两列的表格中
问题描述
我想将帖子标题放在 2 列的表中。
例如:
-------------------------------
post tile 1 | post title 2
-------------------------------
post title 3 | post title 4
-------------------------------
post title 5 | post title 6
我可以打印帖子标题,但如何将所有内容放在表格和列中。
这是我到目前为止写的代码。PS:我对博主主题开发了解不多
代码:
<b:section class='main' id='main' name='Main' showaddelement='yes'>
<b:widget id='Blog1' locked='false' title='Blog Posts' type='Blog'>
<b:includable id='main' var='top'>
<b:include name='allposts'/>
</b:includable>
<b:includable id='allposts'>
<b:loop var='thisPost' values='data:posts'>
<h2>
<a expr:href='data:thisPost.url'> <data:thisPost.title/></a>
</h2>
</b:loop>
</b:includable>
</b:widget>
解决方案
您需要做的就是围绕标题创建一个容器元素并使用 CSSdisplay flex
来布局表格
<b:section class='main' id='main' name='Main' showaddelement='yes'>
<b:widget id='Blog1' locked='false' title='Blog Posts' type='Blog'>
<b:includable id='main' var='top'>
<b:include name='allposts'/>
</b:includable>
<b:includable id='allposts'>
<div class="container">
<b:loop var='thisPost' values='data:posts'>
<h2>
<a expr:href='data:thisPost.url'><data:thisPost.title/></a>
</h2>
</b:loop>
</div>
</b:includable>
</b:widget>
CSS
.container {
display: flex;
flex-wrap: wrap;
}
h2 {
flex: 1 0 45%;
}
结果
.container {
display: flex;
flex-wrap: wrap;
}
h2 {
flex: 1 0 45%;
}
<div class="container">
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
<h2><a href='#'>foo</a></h2>
</div>
推荐阅读
- python - 不能在 python virtualenv 中使用 pip
- vb.net - 如何找出 ExecuteScalar() 是 dbnull
- visual-studio - .net core 的新手,打开了一个 .net core .sln 文件,但所有库(使用)都消失了
- firefox - Firefox启用字体平滑
- apache-spark - Spark 2.3+ 使用 parquet.enable.dictionary?
- c# - 返回行,当唯一键变化发生时
- php - 如果提交的是输入类型文件,则 laravel 中的 required_if 验证不会给出错误
- android - 将字符串转换为链接
- vue.js - 我可以从 vue 自定义指令中获取返回值吗?
- html - 一个图标在另一个前面,与父 div 的右侧对齐