我知道Jupyter使用它自己的CSS样式,这限制了您可以对HTML执行的操作,除非您对其进行编辑。
我尝试用比Python print
更复杂的方式显示一些信息,为此我使用:
from IPython.core.display import display, HTML
display(HTML('<center>some header text</center>')))
所有的东西都是左对齐的--包括文本和表格。有什么简单的解决方法吗?
或者,在Jupyter Notebook中是否有其他方法使表格居中?
发布于 2018-03-04 05:23:11
你可能不得不在html元素中使用一些自定义的CSS。重要的一点是style='margin: 0 auto'
,例如:
from IPython.core.display import display, HTML
display(HTML("""
<table style='margin: 0 auto'>
<tr><th>Hi!</th><th>There!</th></tr>
<tr><td>1</td><td>2</td></tr>
</table>
"""))
https://stackoverflow.com/questions/49089127
复制相似问题