html - 将文本与 CSS 并排放置

标签 html css

我想用 html 制作一个字母模板,如下图所示,其中 nama siswa 将从数据库中填充,因为我们看到冒号总是在同一行。

enter image description here

我试过了

<div class="row">
    <dl class="dl-horizontal">
        <dt>Kelas :</dt><dd>X TIK 1</dd>
        <dt>Wali Kelas :</dt><dd>Mitra Mulyani</dd>
        <dt>Jumlah Siswa :</dt><dd>0</dd>
    </dl>
</div>

并使用 boostrap css 但不适合我的需要。 bootstrap 的结果是这样的 enter image description here 如何用 css 做到这一点?

最佳答案

使用 flex box 来实现它。谢谢

.d-flex p{
width:110px}

.d-flex{
display:flex
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

<div class="col-sm-12">
    <div class="d-flex">
      <p>Kelas </p>
      <p>:X TIK 1</p>
    </div>
    <div class="d-flex">
      <p>Wali Kelas </p>
      <p>:Mitra Mulyani</p>
    </div>
    <div class="d-flex">
      <p>Jumlah Siswa </p>
      <p>:0</p>
    </div>
</div>

关于html - 将文本与 CSS 并排放置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55233719/

相关文章:

css - 如何转换css变量的类型?

html - 将部分的边缘隐藏在其他部分后面

javascript - HTML5;在 Javascript 中检测物理键盘的存在

html - 媒体查询不适用于 415px

css - 响应列中的嵌入视频在 WebKit 中消失

javascript - 如何找到不会破坏给定文本的最大字体大小?

html - 内联显示 : block, 和内联 block 如何工作?

html - 让侧边栏正常运行?

javascript - 使用纯 JavaScript 将十字符号拖放到网格中的框中?

javascript - jquery masonry 响应对齐与窗口调整大小的 Bootstrap