Skip to content

Instantly share code, notes, and snippets.

@paulochf
Last active September 22, 2022 22:22
Show Gist options
  • Star 49 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save paulochf/f6c9ed0b39f85dd85270 to your computer and use it in GitHub Desktop.
Save paulochf/f6c9ed0b39f85dd85270 to your computer and use it in GitHub Desktop.
IPython/Jupyter Notebook enlarge/change cell width
from IPython.display import display, HTML
display(HTML(data="""
<style>
div#notebook-container { width: 95%; }
div#menubar-container { width: 65%; }
div#maintoolbar-container { width: 99%; }
</style>
"""))
@schodge
Copy link

schodge commented May 31, 2017

This was extremely useful, thank you.

@LairBob
Copy link

LairBob commented Jul 6, 2017

This is exactly what I was looking for -- thanks so much.

@febinsathar
Copy link

how do we make this permanent

@paulochf
Copy link
Author

@febinsathar, unfortunately I don't know. I came here today because I couldn't find a way to make it permanent. 😞

@averri
Copy link

averri commented Nov 8, 2017

You don't have to put the configuration in all Notebooks.

Create a file in the location ~/.jupyter/custom/custom.css with the customized CSS content. I have customized in a way to make the Notebook to take advantage of all screen width:

.container {
    width: 99% !important;
}   

div.cell.selected {
    border-left-width: 1px !important;	
}

div.output_scroll {
    resize: vertical !important;
}

It needs to restart the Notebook in order to take effect (just restarting the Kernel does not work).

@ruffsl
Copy link

ruffsl commented Mar 15, 2018

Thanks @averri !
BTW, if I zoom in at 150% or 200% in my browser, I get an extra scroll bar that take up space on the right side (over both toolbar and cells).
Funny enough I don't see it at 175%. Any way to ensure a secondary scrollbar does not appear at any browser zoom level?

@cpatdowling
Copy link

Best gist ever.

@hedifezai
Copy link

awsome ! thanks

@onlinematters
Copy link

onlinematters commented Mar 17, 2019

This was really helpful - thank you! A great find/suggestion. And just to be clear for those who come along - just cut and paste this code in a separate cell at the top of your notebook - you can even do it after the fact and execute it and it works great.

But here is the other question: how do you extend the default height of a cell so that you don't get the scrollbar on the right side (so you can see an entire chart, for example, that you want to make fairly large).

@pakinja
Copy link

pakinja commented Mar 26, 2019

Hello:
I have modified the file custom.css .container { width:100% !important; } so that the notebook occupies 100% of the screen, however when exporting the notebook to html, the result is an html that does not occupy the whole screen (we see all that space on the left and on the right):

note

any suggestions?

Thanks!

@nyck33
Copy link

nyck33 commented Aug 24, 2019

This actually made my working area narrower on a portrait oriented (vertical) monitor on Linux Ubuntu 18.
Similar code on Stackoverflow seems to have made my working area marginally wider.

@julie-data
Copy link

This is so useful, thank you!!!!

@bijoythomas
Copy link

Wonderful! Thank you!

@you-zhou
Copy link

Than you so much. This is really helpful!

@zahirmahammad
Copy link

Thank you very much...... So usefull!!!

@ParthaKarthikeyan
Copy link

Extremely helpful. Thanks!

@skinnedpanda
Copy link

Awesome, I want to give you a hug!

@kauttoj
Copy link

kauttoj commented May 14, 2021

But here is the other question: how do you extend the default height of a cell so that you don't get the scrollbar on the right side (so you can see an entire chart, for example, that you want to make fairly large).

Same question. How do you adjust height, e.g., setting a specific pixel count?

@paulochf
Copy link
Author

@kauttoj should be CSS: height: Kpx;, for K in real numbers.

@PavelEprines
Copy link

Thank you so much

@robertplata
Copy link

Please forgive my naivete, but how and where does one execute:
from IPython.display import display, HTML

display(HTML(data="""

<style> div#notebook-container { width: 95%; } div#menubar-container { width: 65%; } div#maintoolbar-container { width: 99%; } </style>

"""))
??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment