python - IPython 笔记本将代码单元放入列中

标签 python html css ipython jupyter-notebook

有没有办法以列格式组织代码单元?我想在 IPython notebook 中写推导,但每一个辅助方程似乎都破坏了我的推导。我正在使用一个模块来编写我的方程式并将我的方程式输入到代码单元中,所以我不能在 markdown 中使用简单的 html 对齐。非常感谢任何帮助!

我的意思的一个例子是我希望我的代码单元看起来像这样......

enter image description here

而不是常规的垂直对齐单元格...

最佳答案

经过一番挖掘,我通过修改笔记本 css 找到了一个 hackish 解决方案。 这适用于 IPython 2.0,但可能不适用于 1.x! 要测试此方法,只需在笔记本中执行以下命令

%%HTML
<style> 
div#notebook-container.container {
  /* This acts as a spacer between cells, that is outside the border */
  margin: 2px 0px 2px 0px;
  list-style: none;
  padding: 0;
  margin: 0;
  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;  
  justify-content: space-around;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-flex-direction: row;
  flex-direction: row;
}
div.cell {
width:550px
}
  </style>

通过这种方式,您可以获得灵活的盒子布局,因此您可以让两个单元格并排 float 。 由于我不是 CSS 专家,这肯定是一个相当弱的 hack,但它似乎工作合理。要更认真地使用这种方法,您可以创建一个新的配置文件并将 css 添加到您的 custom.css。
我找到了一些灵​​感 here .

结果是这样的
enter image description here

关于python - IPython 笔记本将代码单元放入列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23370670/

相关文章:

python - 艰难地学习 Python 示例 5

html - 使与列表关联的图片成为链接

javascript - 如何从搜索按钮触发 AJAX

css - Bootstrap 4 Card 截断 div 绝对内容

html - CSS 文本翻转效果?

python - @property 是否是一种访问类内私有(private)和 protected 成员的方法?

python - 使用多索引从旋转数据帧获取原始数据帧

Python:将打印函数作为参数发送

javascript - 如何从文本文件动态更改 src?

jquery - 将父 DIV 高度调整为内部内容(RSS 提要)