gpt4 book ai didi

css - 如何将帖子标题放在两列的表格中

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:25 25 4
gpt4 key购买 nike

我想将帖子标题放在 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>

最佳答案

您需要做的就是围绕标题创建一个容器元素并使用 CSS display 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>

关于css - 如何将帖子标题放在两列的表格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58059240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com