html cellpadding 单元格的左侧

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8682719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:13:35  来源:igfitidea点击:

html cellpadding the left side of a cell

html

提问by Night Walker

I want to pad my text in a cells on the right side with additional space .

我想用额外的空间在右侧的单元格中填充我的文本。

I don't use css style sheets .

我不使用 css 样式表。

this is my code <table border="1" CELLPADDING="5">on right size for example I want 10.

这是我<table border="1" CELLPADDING="5">正确大小的代码,例如我想要 10。

Thanks .

谢谢 。

回答by Ben D

This is what css is for... HTML doesn't allow for unequal padding. When you say that you don't want to use style sheets, does this mean you're OK with inline css?

这就是 css 的用途... HTML 不允许不等距填充。当您说您不想使用样式表时,这是否意味着您可以使用内联 css?

<table>
    <tr>
        <td style="padding: 5px 10px 5px 5px;">Content</td>
        <td style="padding: 5px 10px 5px 5px;">Content</td>
    </tr>
</table>

You could also use JS to do this if you're desperate not to use stylesheets for some reason.

如果您出于某种原因不顾一切地不使用样式表,您也可以使用 JS 来执行此操作。

回答by Pegues

I would suggest using inline CSS styling.

我建议使用内联 CSS 样式。

<table border="1" style="padding-right: 10px;">
<tr>
<td>Content</td>
</tr>
</table>

or

或者

<table border="1">
<tr style="padding-right: 10px;">
<td>Content</td>
</tr>
</table>

or

或者

<table border="1">
<tr>
<td style="padding-right: 10px;">Content</td>
</tr>
</table>

I don't quite follow what you need, but this is what I would do, assuming I understand you needs.

我不太了解您的需求,但假设我了解您的需求,这就是我要做的。

回答by Ryan Buddicom

I recently had to do this to create half decent looking emails for an email client that did not support the CSS necessary. For an HTML only solution I use a wrapping table to provide the padding.

我最近不得不这样做,以便为不支持必要 CSS 的电子邮件客户端创建看起来不错的电子邮件。对于仅 HTML 的解决方案,我使用包装表来提供填充。

<table border="1" cellspacing="0" cellpadding="0">
    <tr><td height="5" colspan="3"></td></tr>
    <tr>
        <td width="5"></td>
        <td>
            This cells padding matches what you want.
            <ul>
                <li>5px Left, Top, Bottom padding</li>
                <li>10px on the right</li>
            </ul>    
            You can then put your table inside this
            cell with no spacing or padding set.                    
        </td>
        <td width="10"></td>
    </tr>
    <tr><td height="5" colspan="3"></td></tr>
</table>

As of 2017 you would only do this for old email client support, it's pretty overkill.

截至 2017 年,您只会为旧的电子邮件客户端支持执行此操作,这太过分了。

回答by Umesh Patil

Well, as suggested by Hellfire you can use tdwidth or you could place an element in the td and adjust its width. We could not use

好吧,正如 Hellfire 所建议的,您可以使用td宽度,或者您可以在 td 中放置一个元素并调整其宽度。我们无法使用

CSS property Padding

as in Microsoft Outlookpadding does not work. So what I had to do is,

因为在Microsoft Outlook填充不起作用。所以我必须做的是,

<table>
    <tr>
        <td><span style="display: inline-block; width: 40px;"></span><span>Content<span></td>
        <td>Content</td>
    </tr>
</table>

With this you can adjust right and left spacing. For top and bottom spacing you could use td's height property. Like,

有了这个,您可以调整左右间距。对于顶部和底部间距,您可以使用 td 的高度属性。喜欢,

 <table>
        <tr>
            <td style="vertical-align: top; height: 100px;">Content</td>
            <td>Content</td>
        </tr>
    </table>

This will increase bottom space.

这将增加底部空间。

Hope it will work for you guys. :)

希望它对你们有用。:)

回答by nathanjessen

I choose to use both methods. Cellpadding on the table as a fallback in case the inline style doesn't stick and inline style for most clients.

我选择同时使用这两种方法。表格上的 Cellpadding 作为后备,以防内联样式不适用大多数客户的内联样式。

<table cellpadding="5">
  <tr>
    <td style='padding:5px 10px 5px 5px'>Content</td>
    <td style='padding:5px 10px 5px 5px'>Content</td>
  </tr>
</table>

回答by user5719947

I use inline css all the time BECAUSE.... I want absolute control of the design and place different things aligned differently from cell to cell.

我一直使用内联 css,因为....我想要绝对控制设计并将不同的东西从单元格到单元格以不同的方式对齐。

It is not hard to understand...

不难理解...

Anyway, I just put something like this inside my tag:

无论如何,我只是在我的标签中放了这样的东西:

style='padding:5px 10px 5px 5px'

style='padding:5px 10px 5px 5px'

Where the order represents top, right, bottom and left.

其中顺序代表上、右、下和左。