Reputation: 16247
Liking the dark background in this notebook, I grabbed the author's CSS file from the gist, and applied the following in my own notebook (exactly as the author has done):
from IPython.core.display import HTML
styles = open("custom_dark.css", "r").read()
HTML(styles)
While it has applied a dark background, the styling has also gotten rid of everything else on the page but the cells. So no menus at the top, etc. Even having closed and re-opened the notebook, and restarting the kernel, the dark affect and the loss of page elements persists.
How can I revert the styling (to no styling at all)?
Upvotes: 1
Views: 1353
Reputation: 20972
If you've jacked the HTML/CSS of the notebook up royally, try clearing the outputs:
Cell
> All Outputs
> Clear
Upvotes: 0
Reputation: 828
The file "custom_dark.css"
is actually an html fragment containing a <style>
tag and posing as a css file.
When you "display" it by calling the HTML
function, the fragment is inserted in the DOM inside a special div in the cell output area, causing a global change to the style of the html page.
When you save the resulting notebook, all output is serialized as JSON and saved, including the DOM fragment you created before.
When you load it again, the engine restores the output thus saved; therefore it recreates the DOM insert, and the custom style is applied again by your browser.
Right now I can think of two ways of restoring the default style; both consist in removing the output for the cell:
you manage to execute the same cell, but without the HTML()
call; this changes the output div to one without the <script>
insert, and the browser interprets this as removing the custom css layer; then you save again;
or, you manually edit the .ipynb
file and remove the culprit, that is, the serialized output ; it should be under the "outputs"
key of the (JSON) object that represents the cell (look for a "text/html"
member and remove it entirely); you can then load the file again.
Upvotes: 2