如何将内容分成几行?

huangapple go评论137阅读模式
英文:

how to div in few rows seperatly?

问题

[![输入图像描述][1]][1]顶部、中部、底部的简单代码div...................................................
<top>
<div class="top">测试</div>
<div class="top">测试</div>
<div class="top">测试</div>
</top>
<middle>
<div class="middle"><p>测试</p></div>
<div class="middle">测试</div>
<div class="middle">测试</div>
</middle>
<bot>
<div class="bot"><p>测试</p></div>
<div class="bot">测试</div>
<div class="bot">测试</div>
</middle>
</bot>
英文:

如何将内容分成几行?Simple code div in top, mid, bot...................................................

    <top>
    <div class="top">test</div>
    <div class="top">test</div>
    <div class="top">test</div>
    </top>
<middle>
        <div class="middle"><p>test</p></div>
        <div class="middle">test</div>
        <div class="middle">test</div>
        </middle>
        <bot>
            <div class="bot"><p>test</p></div>
            <div class="bot">test</div>
            <div class="bot">test</div>
            </middle>
        </bot>

答案1

得分: 2

你可以在项目上使用弹性盒子。这些项目中包含你的文本:https://www.w3schools.com/css/css3_flexbox.asp

如果你想要一个<div>而不是<p>,你可以更改它们,但请确保你更改了应用在这些<div>上的类的样式(CSS)。

有多种弹性盒子的设置可用于自定义布局,你可以在互联网上找到它们。

你也可以使用网格布局:https://www.w3schools.com/css/css_grid.asp

.item {
  display: flex;
  justify-content: space-around;
}

p {
  border: solid;
  width: 50px;
  height: 50px;
}
<div class="container">
  <div class="item">
    <p>
      test1
    </p>
    <p>
      test2
    </p>
    <p>
      test3
    </p>
  </div>
  <div class="item">
    <p>
      test1
    </p>
    <p>
      test2
    </p>
    <p>
      test3
    </p>
  </div>
  <div class="item">
    <p>
      test1
    </p>
    <p>
      test2
    </p>
    <p>
      test3
    </p>
  </div>
</div>
英文:

You can put a flexbox on a items. In those items are your text: https://www.w3schools.com/css/css3_flexbox.asp

If you want a div instead of a p you can change them but make sure you change the style (css) to the class you put on those div's

There are multiple settings for flexbox to customize your layout. you can find them on the internet.

You can also use a grid: https://www.w3schools.com/css/css_grid.asp

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.item{
  display: flex;
  justify-content: space-around;
}

p{
  border: solid;
  width: 50px;
  height: 50px
}

<!-- language: lang-html -->

&lt;div class=&quot;container&quot;&gt;
  &lt;div class=&quot;item&quot;&gt;
   &lt;p&gt;
     test1
   &lt;/p&gt;
   &lt;p&gt;
     test2
   &lt;/p&gt;
   &lt;p&gt;
     test3
   &lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=&quot;item&quot;&gt;
   &lt;p&gt;
     test1
   &lt;/p&gt;
   &lt;p&gt;
     test2
   &lt;/p&gt;
   &lt;p&gt;
     test3
   &lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=&quot;item&quot;&gt;
   &lt;p&gt;
     test1
   &lt;/p&gt;
   &lt;p&gt;
     test2
   &lt;/p&gt;
   &lt;p&gt;
     test3
   &lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年3月7日 19:42:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661541.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定