Button pushing content down on hover - html

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*/

Related

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

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.

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

CSS overflow:hidden creating margin at bottom

When I add
overflow:hidden
to any of the buttons on my page, it creates 13px of margin at the bottom of the button. When I remove the above CSS, the margin disappears, however some content inside the button overflows.
How can I remove the margin at the bottom, while keeping the
overflow:hidden
CSS style?
WITH overflow:hidden
WITHOUT overflow:hidden
, however, the Facebook logo overflows into the next button (it is a custom font)
CURRENT BUTTON CSS:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
CURRENT BUTTON HTML:
<a class="btn btn-fb btn-xl" id="login_fb"><span class="icon-socialfacebookvariant"></span>Log In</a>
CURRENT FACEBOOK LOGO CSS:
[class^="icon-"], [class*=" icon-"] {
overflow:hidden;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size:2em;
line-height:0;
font-family: 'icomoon';
position:relative;
top:-1px;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
vertical-align:middle;
}
// Facebook logo from a font
.icon-socialfacebookvariant:before {
content: "\e9e3";
}
Thanks Jaunt for the help.
Although your idea is the most logical, it's not very nice when editing!
Luckily I happened to come across a simple fix to my problem!
All I had to do was add vertical-align:top to my button CSS, and wham! it works!
Thanks for your help :)
It's because you have white-spacing between the HTML elements. This snippet is with the white-spacing:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
And this one is without:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
<div class="btn"></div><div class="btn"></div><div class="btn"></div><div class="btn"></div><div class="btn"></div>
There is a notable difference and I believe this is where your mysterious margin is coming from.

Button with a bigger text centering issue

I´m trying to do some buttons with image and text, and I already did this work.
But now I´m studying a diferente hypothesis, If I have a text bigger I´m trying to center the text in the button but I´m not having sucess put this right. I´m not having succeess putting my very big is not good align-center just below the 1st text.
Have you ever had a case like this? How we can solve this?
I have this Html for two buttons:
<button class='btn'>
<img class="big_btn" src="icon1.png" width="40" height="40"/>
Big button so big <span> very big is not good</span>
</button>
<button class='btn'>
<img src="icon1.png" width="40" height="40">
2button big
</button>
And I have this css file:
.btn {
position: relative;
width: 180px;
height: 60px;
margin-top:7%;
padding: 0 10px 0 10px;
line-height: 37px;
text-align: left;
text-indent: 10px;
font-family: 'bariol_regularregular';
font-size: 15px;
color: #333;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
background: #f1f1f1; /* button background */
border: 0;
border-bottom: 2px solid #999; /* newsletter button shadow */
border-radius: 14px;
cursor: pointer;
-webkit-box-shadow: inset 0 -2px #999;
box-shadow: inset 0 -2px #999;
}
.btn:active {
top: 1px;
outline: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn img { float: left;}
.btn .big { margin-top:10px;}
.btn:hover { background-color: #f7f7f7;}
Here's the Fiddle: http://jsfiddle.net/3F9pu/
My image updated:
Your problem is your line-height attribute. If you set that to be 37px, each new line of text will be separated by 37px. Remove `line-height:37px and the text will wrap around the image.
line-height: 37px
I also removed your text-indent and replaced it with a margin on your floated image to make the text all align properly.
.btn img{
float:left;
margin-right: 10px;
}
text-indent: 10px
JSFiddle
Use a CSS background image.
Have a fiddle - Fiddle Link!
HTML
<button class='btn'>Big button so big very big is not good</button>
<button class='btn'>2button big</button>
CSS
.btn {
background: url("http://lorempixel.com/output/cats-q-c-40-40-3.jpg") #CCC 10px no-repeat;
border: none;
padding: 10px 10px 10px 60px;
width: 200px;
text-align: left;
vertical-align: top;
min-height: 60px;
cursor: pointer;
}
.btn:hover {
background-color: #F00;
}

CSS Tooltip has different position in different browsers. How can I account for this?

I have adjusted my bottom attribute to display how I want it in Firefox, but the spacing is all warped in Chrome and Safari. Is there a way to sett a different "top" attribute for each browser?
HTML
<a class="tooltip" href="#"> <!-- this tag activates my tool tip -->
<div class="handsevent" > <!-- this div contains everything that activates the tool tip when hovered over-->
<div class="handswrapper">
<div class="handshour" >
<h3>8:00am-noon</h3>
</div>
<div class="handsspeaker">
<h3>Speaker 3</h3>
</div>
</div>
<div class="handstitle">
<p>Description</p>
</div>
</div>
<span class="classic"> <!-- this span contains everything that pops up in the tool tip -->
<h3>Title Bar</h3>
<br />lots of descriptive text
</span>
</a>
CSS
/* HOVER WINDOW */
.tooltip {
color: #000000; outline: none; font-style:bold;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 30px 30px; -moz-border-radius: 30px; -webkit-border-radius: 30px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Arial, Tahoma, Helvetica, sans-serif;
position: auto; left: 1em; top: 2em; z-index: 99; <!-- the 'top' attribute on this line is where I have been adjusting the display position it affects the position differently in different browsers -->
margin-left: 0; width: 700px; margin-top:-10px;
}
.tooltip:hover img {
border: 0; margin: -30px 0 0 90px;
float: right; position:fixed;
z-index: 99;
}
.tooltip:hover em {
font-family: Arial, Tahoma, Helvetica, sans-serif; font-size:14px; font-weight: bold; color:005DA4;
display: block; padding: -0.2em 0 0.6em 0;
}
.classic { padding: 0.8em 1em; }
* html a:hover { background: transparent; }
.classic {background: #ffffff; border: 1px solid #ffffff; }
I have tried pixels, em, and percentage. None of these have been consistent. Are there browser specific settings I could use?
here is a demo link for reference.
Using a CSS Reset will help to eliminate differences between browsers.
I switch the top attribute in ".tooltip:hover span" to "auto" and that seems to be working.