Bootstrap 如何在文本和按钮之间添加空格而不使用< br />

balp4ylt  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(189)

如何在文本和按钮之间添加空格而不使用
我的意思是,让第一个按钮上的“你好吗”和第二个按钮上的“你好吗”之间不要太靠近。

<p>
      How are you doing?
      <br />
      <br />
      <button class='btn btn-default btn-xs pull-left'>
          Cancel
      </button>
      <button class='btn btn-danger btn-xs pull-right'>
          Confirm
      </button>
      <br />
  </p>
bvjveswy

bvjveswy1#

Spacing on web pages can be achieved primarily via the margin and padding CSS properties.
Put simply: padding affects spacing inside your element and margin affects spacing outside your element.
I'd recommend having a quick read of CSS Box Model to get to grips with the subject.

  • Padding* and margin can be set using all sorts of units. E.g., pxemrem and even % .

You could set margin top in CSS like so:

.my-css-class {
   margin-top: 50px;
}

You can apply CSS directly to elements like so:

<p>
      How are you doing?
      <br />
      <br />
      <button style="margin-top: 2em" class='btn btn-default btn-xs pull-left'>

Although I wouldn't suggest making this a habit as it could potentially make maintaining your code significantly more difficult.

相关问题