有关如何使用边距的信息

发布于 2024-07-05 06:26:45 字数 105 浏览 12 评论 0原文

我需要一些有关如何使用边距以及填充到底如何工作的信息。

例如:我应该放一条线来占据页面的整个宽度(无论使用什么分辨率来显示网页),而在每一侧只留一个小边框,我该如何实现这一点?

I need some info on how to use margins and how exactly padding works.

For example: Should I put a line to occupy the whole width of the page (no matter what resolution is used to display the web page) letting just a small border on each side, how could I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

太阳哥哥 2024-07-12 06:26:45

看看这个: http://redmelon.net/tstme/box_model/

基本上,元素由内容组成,周围是填充,然后是边框,然后是边距。 背景图像仅延伸至边界。 边距最好描述为“该元素周围的空白”。

但是看看上面的 URL,并为自己制作一个测试页面来玩一下,这应该都是有意义的。

Have a look at this: http://redmelon.net/tstme/box_model/

Basically, an element consists of content, surrounded by its padding, then the border, then the margin. Background images only extend as far as the border. Margins are best described as 'the whitespace around this element'.

But have a look at the URL above, and make yourself a test page to have a play with, it should all make sense.

唐婉 2024-07-12 06:26:45

我认为这应该满足您的要求:

<table width="100%" cellpadding="5">
  <tr>
    <td>
One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... 
    </td>
  </tr>
</table>

将宽度设置为“100%”会强制文本使用完整宽度,并将 cellpadding 设置为“5”会设置 5 像素的不可见边框。

I think this should do what you want:

<table width="100%" cellpadding="5">
  <tr>
    <td>
One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... 
    </td>
  </tr>
</table>

Setting width to "100%" forces the text to use the full width, and setting cellpadding to "5" sets a unvisible border of 5 pixels.

狂之美人 2024-07-12 06:26:45

另一种说明方式是在盒子模型中,填充是盒子的内部“边距”,边距是盒子周围的缓冲区。

Another way to illustrate it is in the box model, padding is the inside "margin" of a box margin is the buffer around the box.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文