Skip to content

Instantly share code, notes, and snippets.

@mccurcio
Last active August 18, 2021 17:18
Show Gist options
  • Save mccurcio/b3ee264b96a79ef9ed5b906a01d8de49 to your computer and use it in GitHub Desktop.
Save mccurcio/b3ee264b96a79ef9ed5b906a01d8de49 to your computer and use it in GitHub Desktop.
Change Ipython Cell Width.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": false
},
"cell_type": "markdown",
"source": "# Change Ipython Cell Width\n\n2021-08-17 11:06:13 \n\nThe snippet in this ipython jupyter notebook expands the width of the code and result cells to be 100% of the width of the browser. \n\nThis code allows one to ONLY change the notebook it is running on.\n\nBy changing the `width` and `max-width` parameters below you can change sizes.\n\nIpython Notebook meta data (run with)\n\n```html\n{\n \"kernelspec\": {\n \"name\": \"python3\",\n \"display_name\": \"Python 3\",\n \"language\": \"python\"\n },\n \"language_info\": {\n \"name\": \"python\",\n \"version\": \"3.8.8\",\n \"mimetype\": \"text/x-python\",\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"pygments_lexer\": \"ipython3\",\n \"nbconvert_exporter\": \"python\",\n \"file_extension\": \".py\"\n }\n}\n```"
},
{
"metadata": {
"trusted": true
},
"id": "1b537118",
"cell_type": "code",
"source": "from IPython.core.display import display, HTML\ndisplay(HTML(\"<style>.container { width:100% !important; }</style>\"))\ndisplay(HTML(\"<style>.output_result { max-width:100% !important; }</style>\"))",
"execution_count": 1,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": "<style>.container { width:100% !important; }</style>"
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": "<style>.output_result { max-width:100% !important; }</style>"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.8",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Change Ipython Cell Width.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment