我可以在html5中设置制表位置吗?

前端之家收集整理的这篇文章主要介绍了我可以在html5中设置制表位置吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在 html5中设置制表位,并能够将文本对齐,就像在Word中一样.对于我的应用程序,我不能使用表.有没有办法做到这一点?我必须使用 Javascript吗?

解决方法

尽管其他海报的说法是相反的,但是有理由想要做OP所要求的方法,并且使用现代CSS(以及我在编写规范过程中的更多内容)来执行此操作.这只是一种方法.
<!DOCTYPE HTML>
<html>
 <head>
  <title>Tabs with css</title>
  <style>
  {body: font-family: arial;}
  div.row span{position: absolute;}
  div.row span:nth-child(1){left: 0px;}
  div.row span:nth-child(2){left: 250px;}
  div.row span:nth-child(3){left: 500px;}
  </style>
 </head>
 <body>
  <div class="row"><span>first row data before first tab</span><span>data left aligned with first tab</span><span>data aligned with second tab</span></div><br>
  <div class="row"><span>second row data before first tab</span><span>data left aligned with first tab</span><span>data aligned with second tab</span></div><br>
  <div class="row"><span>third row data before first tab</span><span>data left aligned with first tab</span><span>data aligned with second tab</span></div><br>
  <div class="row"><span>fourth row data before first tab</span><span>data left aligned with first tab</span><span>data aligned with second tab</span></div><br>
  <div class="row"><span>fifth row data before first tab</span><span>data left aligned with first tab</span><span>data aligned with second tab</span></div><br>
 </body>
</html>

请参见以下示例结果:http://jsfiddle.net/Td285/

另外一个例子,溢出被剪辑:http://jsfiddle.net/KzhP8/

猜你在找的HTML5相关文章