Javascript 在 html 中插入一个制表符或空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27402840/
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
Insert a tab or spaces in html
提问by President Camacho
I'm new to html and I got this piece of code:
我是 html 的新手,我得到了这段代码:
@{
ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>View1</title>
<script src="~/Scripts/jquery-1.9.1.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<table>
@foreach (var item in Model.Data)
{
<tr>
<td><a [email protected][item.Key]>@item.Key</a></td>
<td>@item.Value</td>
</tr>
}
</table>
</body>
</html>
I want to add a tab or spaces between: <td><a [email protected][item.Key]>@item.Key</a></td>and <td>@item.Value</td>how do I do that?
我想添加一个标签或之间的空间:<td><a [email protected][item.Key]>@item.Key</a></td>与<td>@item.Value</td>我该怎么做呢?
I guess adding css is the best way but I don't understand how to use it.
我想添加 css 是最好的方法,但我不明白如何使用它。
采纳答案by JLRishe
You can add padding to your tdwith CSS:
您可以td使用 CSS向您添加填充:
td {
padding-right: 30px;
}
<table>
<tr>
<td><a href="#">Hello</a></td>
<td>Goodbye</td>
</tr>
<tr>
<td><a href="#">Hola</a></td>
<td>Adios</td>
</tr>
</table>
or give them a fixed width:
或者给他们一个固定的宽度:
td {
min-width: 200px;
}
<table>
<tr>
<td><a href="#">Hello</a></td>
<td>Goodbye</td>
</tr>
<tr>
<td><a href="#">Hola</a></td>
<td>Adios</td>
</tr>
</table>
回答by Deblaton Jean-Philippe
` ` is a space
`	` is a tab
Just insert them where you want
只需将它们插入您想要的位置
For the CSS, you should use the padding property, there are plenty of tutorials on the web, and samples
对于 CSS,你应该使用 padding 属性,网上有很多教程和示例
回答by FDM
回答by Djoezz
<table style="border-spacing: 10px;">
Or in a CSS block somewhere:
或者在某个 CSS 块中:
table {
border-spacing: 10px;
}

