Is there some way to display alert boxes on google colab? - html

To display nice boxes on Jupyter Notebooks, it is possible to use alert HTML tags and put inside some markdown content.
Here an example displayed on a Jupyter Lab instance :
<div class="alert alert-info" role="alert" style="color: rgba(0,0,0,.8); background-color: white; margin-top: 1em; margin-bottom: 1em; margin:1.5625emauto; padding:0 .6rem .8rem!important;overflow:hidden; page-break-inside:avoid; border-radius:.25rem; box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .05rem rgba(0,0,0,.1); transition:color .25s,background-color .25s,border-color .25s ; border-right: 1px solid #dee2e6 ; border-top: 1px solid #dee2e6 ; border-bottom: 1px solid #dee2e6 ; border-left:.2rem solid #007bff80;">
<h3 class="alert-heading"><i class="fa fa-comment"></i> Note</h3>
An example of a nicely formatted box
</div>
This can even be simplified to basic alerts :
<div class="alert alert-info" role="alert">
<h3 class="alert-heading">Note</h3>
An example of a nicely formatted box
</div>
However, the same notebook does not render well on Google Colab:
Example notebook here

Maybe make your own classes. following code works both in collab and jupyter
You can use the HTML magic command to display the HTML code directly
from IPython.core.display import HTML
HTML("""
<div class="alert">
<p>This is an alert box.</p>
</div>
<style>
.alert {
padding: 20px;
background-color: #f44336;
color: white;
margin-bottom: 15px;
}
</style>
""")

It's highly probably that classes alert-* are pre-defined in Jupyter Notebook, but not in Google Colab. I see a simple solution — just define these classes yourself, maybe like this:
.alert {
border-radius: 10px;
background-color: #bbb;
border: 2px solid #999;
margin-top: 20px;
margin-bottom: 20px;
padding-left: 5px;
padding-top: 10px;
padding-bottom: 10px;
font-family: 'Arial', sans-serif;
}
.alert > h3 {
display: block;
font-size: 30px;
margin-top: 5px;
margin-bottom: 15px;
}
.alert-info {
background-color: #1af !important;
border: 2px solid #04a !important;
}
<div role="alert" class="alert alert-info">
<h3>Note</h3>
An example of a nicely formatted box
</div>
Or maybe change the colors (1af etc.).
If you need a better box than the one that appears if you run the above snippet, you may use the style from your first example of a nice box.
UPDATE: a box using your style.
.alert {
border-radius: 10px;
background-color: #bbb;
border: 2px solid #999;
margin-top: 20px;
margin-bottom: 20px;
padding-left: 5px;
padding-top: 10px;
padding-bottom: 10px;
font-family: 'Arial', sans-serif;
}
.alert > h3 {
display: block;
font-size: 30px;
margin-top: 5px;
margin-bottom: 15px;
}
.alert-info-stylish {
color: rgba(0,0,0,.8) !important;
background-color: white !important;
margin-top: 1em !important;
margin-bottom: 1em !important;
margin: 1.5625emauto !important;
padding: 0 .6rem .8rem !important;
overflow: hidden !important;
page-break-inside: avoid !important;
border-radius: .25rem !important;
box-shadow:0 .2rem .5rem rgba(0,0,0,.05), 0 0 .05rem rgba(0,0,0,.1) !important;
transition: color .25s, background-color .25s, border-color .25s !important;
border-right: 1px solid #dee2e6 !important;
border-top: 1px solid #dee2e6 !important;
border-bottom: 1px solid #dee2e6 !important;
border-left:.2rem solid #007bff80 !important;
}
<div role="alert" class="alert alert-info-stylish">
<h3>Note</h3>
An example of a nicely formatted box
</div>

Maybe as an idea, run it as snipped as a python code block:
##title Alert Notification
from IPython.display import HTML
alert_info = '''
<div class="alert alert-info" role="alert">
<h3 class="alert-heading">Note</h3>
An example of a nicely formatted box
</div>
'''
display(HTML('<link href="https://nbviewer.org/static/build/styles.css" rel="stylesheet">'))
display(HTML(alert_info))
Text cells are formatted using a markdown language version which is also uses at GitHub. The support for this feature on GitHub is still being discussed.
I use the UTF-8 icons combined with a quote block:
> # 🗒 Info
> This is a note.
> # ⚠ Warning
> This is a warning.
> # ⛔ Alert
> This is an alert.

Related

Button pushing content down on hover

I'm working on a website and I have run into a little problem I can't really solve. Basically, I have a credits button that is supposed to have some effects when the user hovers over it. However, if I hover over the button it's pushing down all the contents on the page.
I have tried to solve it quite a bit but sadly I couldn't find a solution. I'm sure I could find a solution sooner or later but I'm on a schedule and have to get some other things on the page done, so I will need to focus on that.
.creditsbtn {
font-family: 'Courier New', Courier, monospace;
color: #333;
background: #AB5DFC;
border-radius: 10px;
border: #AB5DFC;
padding-top: 5px;
padding-bottom: 7px;
padding-right: 10px;
padding-left: 10px;
font-size: 20px;
}
.creditsbtn:hover {
transform: translateY(-5px);
color: #333;
box-shadow: .0rem .2rem .4rem #777;
border: 5px solid #b16afd;
pointer-events: visible;
position: relative;
z-index: 0;
visibility: visible;
float: none;
}
<h2>header 1</h2>
<p style="text-align: center">some text<br><br>
<button class="creditsbtn">button</button></p>
<br><hr>
<h2>header 2</h2>
<p style="text-align: center">some more text<br><br></p>
Try doing as below (I added comments in my code). The trick is to have that border from the beginning but with a transparent colour, and just change the colour on hover.
.creditsbtn {
font-family: 'Courier New', Courier, monospace;
color: #333;
background: #AB5DFC;
border-radius: 10px;
/* line I added */
border: 5px solid transparent;
padding-top: 5px;
padding-bottom: 7px;
padding-right: 10px;
padding-left: 10px;
font-size: 20px;
}
.creditsbtn:hover {
transform: translateY(-5px);
color: #333;
box-shadow: .0rem .2rem .4rem #777;
/* line I added */
border-color:#b16afd;
pointer-events: visible;
position: relative;
z-index: 0;
visibility: visible;
float: none;
}
<h2>header 1</h2>
<p style="text-align: center">some text<br><br>
<button class="creditsbtn">button</button></p>
<br><hr>
<h2>header 2</h2>
<p style="text-align: center">some more text<br><br></p>
The animation change a little bit from what you have, but this way you can avoid that pushing problem you have.
Instead of having a border which is pushing the other content down. You could have a solid box-shadow the same colour as the button. This would enlarge the box on-hover without affecting other content. Then add a second box-shadow for the shadowing effect.
box-shadow: 0px 0px 0px 10px #color, 0px 8px 8px #000;
/* before the comma is your enlarged border but set your color.
After the comma is an actual shadow currently set to black*/

CSS button does not highlight properly

I have this button which doesn't highlight properly when I click on it, please see the image, and CSS file down below
CSS for the toggle button:
.mat-button-toggle {
box-sizing: border-box;
height: 33px;
width: 159px;
border: 1px solid #E1E1E1;
border-radius: 2px;
background-color: #FFFFFF;
}
.mat-button-toggle:hover {
border: 1px #000 solid !important;
background-color: #FFF !important;
border-radius: 5px !important;
}
CSS for the text
.ticket {
margin-top: 5px;;
height: 18px;
width: 122px;
color: #111111;
font-family: Arial;
font-size: 16px;
letter-spacing: 0;
line-height: 18px;
}
HTML
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" >
<mat-button-toggle routerLink="ticketView" value="ticketView">
<div class="ticket" id="p1">
{{'TicketOverView' | translate}}
</div>
</mat-button-toggle>
My guess is there is something else in your css html going on. I have recreated your css in codepen for you and couldn't reproduce your results.
I would double check your html markup.
Here is the codepen I produced
https://codepen.io/jmllr89/pen/KKdzLGw
Also you do not need !important on the :hover pseudo-class. CSS is smart enough to recognize what needs to be changed. So simply define your initial state in mat-button-toggle and then in mat-button-toggle:hover you create a second state, and css will make the necessary changes.
.mat-button-toggle {
height: 33px;
width: 159px;
border: 1px solid #E1E1E1;
border-radius: 2px;
background-color: #FFFFFF;
}
.mat-button-toggle:hover {
border-color: #000;
border-radius: 5px;
}

Aligning items inside a button

I'm trying to align a triangle next to written text in a button using only HTML and CSS. For the life of me, I can remember how.
.room-info-btn {
background-color: #FFA500;
color: #fff;
border-radius: 4px;
padding: 5px 11px;
font-size: 20px;
}
.arrow-down {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #fff;
}
<li>
<button class="room-info-btn" id="room-info-btn">
<div class="arrow-down"></div>
Rooms / Availability
</button>
</li>
I highly recommend checking out Flexbox.
For your code, you can simply add the following css to your .room-info-btn selector:
display: flex;
align-items: center;
This makes aligning many items very simple and gives you other flex control options.
Try this. Flexbox is a better choice I guess.
Take a look here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.room-info-btn {
background-color: #FFA500;
color: #fff;
border-radius: 4px;
padding: 5px 11px;
font-size: 20px;
display: flex;
align-items:center;
}
.arrow-down {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #fff;
}
<li>
<button class="room-info-btn" id="room-info-btn">
<div class="arrow-down"></div>
Rooms / Availability
</button>
</li>
Try display: inline-table; in arrow-down class to align with the text

Custom radio button not visible in iOs Safari

I am using below mentions css to show cutom radio buttons
input[type=radio]{
display:none;
}
.radio-options label::before {
content: "\2b24";
color:#e2e2e2;
display: inline-block !important;
width: 17px;
height: 17px;
vertical-align:middle;
margin-right: 8px;
background-color: #fff;
border: 1px solid #e2e2e2;
border-radius: 8px;
font-size: 9px;
text-align: center;
text-shadow: 0px 0px 3px #fff;
font-family: monospace;
padding-top: 1.8px;
line-height: 10px;
cursor: pointer;
}
.radio-options label.active-radio::before {
content: "\2b24";
color: #f9b410;
background-color: #fff;
font-size: 9px;
text-align: center;
text-shadow: 0px 0px 3px #fff;
font-family: monospace;
margin-left: 0px;
padding-top: 1.8px;
line-height: 10px;
}
<div class="radio-options">
<div class="col-md-6 col-xs-6">
<input id="some_thing" type="radio" >
<label ng-class="{'active-radio':true}">Something</label >
</div>
</div>
In desktop browser it's working correctly and showing radio button as
But in safari iOs its not displaying anything
Any suggestions what could be possible cause ?
It is because of the Unicode symbol you use as a content. It doesn't seem to appear on iOS. If you change to "Black Circle" instead it will work. (Just increase the font-size to compensate the size.)
Unicode Black Circle symbol
Similar issue

position of website elements

I have an issue with rendering my website for IE, Chrome and Opera. In Firefox the positioning works well:
while in the other browsers it looks like crap:
I have tried several positioning and padding options, but no luck. The problems appeared as I replaced the drop down menu with a jQuery replacement to enhance it graphically. The original dropdown is still there but with the css-option "display: none". I'd be thankful for a hint!
Here is the css:
This is the big blue box
.searchHomeForm a, .searchHomeForm a:hover {
color:#000000;
}
A invisible box around the three elements
div.searchHomeForm , .searchform {
height: 37px;
margin-left: auto;
margin-right: auto;
}
The white search bar
.search_bar {
position: inherit;
height: 25px;
letter-spacing: 0.02em;
line-height: 25px;
padding: 9px 0 0px 9px;
width: 390px;
border: 1px solid #95B6D6;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.11) inset;
border-radius: 0.25em 0 0 0.25em;
}
the jQuery Dropdown replacement
#searchformReplacement {
background: #EBEBEB;
padding: 0px 1px 5px 0;
margin-bottom: 3px;
border-top: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
width: 109px;
position: inherit;
}
the find button
.find_button {
background: url("../images/lupevufindsearchsubmit1.png") no-repeat scroll #bBbBbB;
-moz-border-radius: 0.25em;
border-radius: 0 0.25em 0.25em 0;
position: inherit;
height: 36px;
line-height: 36px;
margin: 0px 0 3px -1px;
padding: 4px 10px 4px 10px;
width: 60px;
border-top: 1px solid #95B6D6;
border-right: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
border-left: none;
box-shadow: 2px 2px 5px rgba(76, 133, 187, 0.50) inset;
transition: all 0.2s ease-in-out 0s;
}
Try removing position: inherit from the .search_bar {}, #searchformReplacement {}and .find_button {} add display:inline-block for each
or add display:inline and float:left for each. You may have to clear floats if you use float:left
maybe use float: left; on the three elemetns next to each other?
I made you a little example to have the required position, I'm using the inline-block propriety (and I love it) :
Html
<div id="container">
<input type="text" class="inline-block" />
<div class="inline-block">
Your custom select
</div>
<button type="submit" class="inline-block">Search</button>
</div>
CSS
.inline-block {
display:inline-block;
*display:inline; /*IE hack*/
*zoom:1; /*IE hack*/
}
#container {
background:lightBlue;
width:300px;
margin:0 auto;
text-align:center;
}
See the working fiddle !
Yes, clearing your floats are important as madhushankarox has pointed out. But you don't always need to use floats, especially not in your case. Plus here's an extra bonus if you ever need to place your form into a liquid layout page. It should proportion itself out equally on most screens that are wide or thin.
CSS
/*the blue rounded box*/
#bluebox {
padding:3% 5%;
margin:0 25%;
background:#d0dcea;
border:solid 1px #b7c2d2;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.fieldset-search {
text-align:center;
}
/*The white search bar*/
.input-search {
padding:5px;
margin:0;
width:50%;
vertical-align: baseline;
border: solid 1px #b7c2d2;
background: #fff;
outline: 0;
}
/*the jQuery Dropdown replacement*/
.list-search {
padding:4px;
margin:0 0 0 -5px;
}
/*the find button*/
.submit-search {
padding:4px 10px;
margin:0 0 0 -5px;
}
HTML
<div id="bluebox">
<div class="fieldset-search">
<input type="text" name="search" class="input-search">
<select name="list" class="list-search"><option></option></select>
<button type="search" class="submit-search">Go</button>
</div>
</div>