Button text won't be displayed properly in browsers other than Firefox - html

So I'm studying javascript and I had to do Pokemon-themed app. My goal was to create a Pokeball shaped button and it looked actually pretty decent, but then I deploy it and my friends start notifying me that the button looks awful. I tested it on Chrome, Edge and Brave and it looks bad in all of them, Firefox being the only exception.
So this is my CSS code (I'm using styled components):
const PokeButton = styled.button`
border-radius: 100%;
border: 3px solid black;
width: 3rem;
height: 3rem;
padding-inline: 0 0;
outline: 2px solid black;
border: 2px solid white;
text-shadow: 2px 0 0 #000, -2px 0 0 #000,
0 2px 0 #000, 0 -2px 0 #000, 2px 2px 0 #000,
-2px -2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000;
-webkit-text-fill-color: white;
background: linear-gradient(180deg, rgb(239, 21, 21) 50%, white 50%);
&:hover {
transition: .5s;
transform: rotate(15deg);
width: 3.6rem;
height: 3.6rem;
}
&:active {
transition: .2s;
transform: rotate(-45deg);
width: 2.6rem;
height: 2.6rem;
padding-inline: 0 1rem;
}
transition: .2s;
margin-left: 1rem;
overflow: hidden;
cursor: pointer;
`;
And here is my HTML for the Button:
<PokeButton type="submit" >―⬤—</PokeButton>
The problem I have is that on Firefox, the overflow is hidden properly, but in the rest of browsers, the first em-dash and the circle are in the upper half of the ball -and not centered- while the second dash is in the lower half (except on hover, where it looks the way it should). On Firefox, they're all in the middle and the circle is centered.
What can I do to fix this?

Related

Safari (Webkit) displays shadow incorrectly (filter: drop-shadow)

I recently created a searchbar with a shadow effect on hover, it works correctly on all browsers except on Safari (Desktop), tested on Version 13.1.1 (15609.2.9.1.2). There the shadow seems to not go out of the div.
The shadow was created with
filter: drop-shadow(0 1px 5px rgba(0, 0, 0, 0.1));
I also tried -webkit-filter unsuccessfully. As well as fixing it with overflow: visible
Here is a short vid of the bug: https://imgur.com/a/aBafuXl
You can test it yourself by creating this html file
.searchbar {
width: 500px;
height: 70px;
margin: auto;
border-radius: 35px;
background: white;
border: 1px gray solid;
}
.searchbar:hover {
filter: drop-shadow(0 1px 5px rgba(0, 0, 0, 0.1));
border: 1px solid white;
}
<div class="searchbar"></div>
Have you tried using box-shadow instead of filter drop-shadow
.searchbar {
width: 500px;
height: 70px;
margin: auto;
border-radius: 35px;
background: white;
border: 1px gray solid;
transition: filter .1s;
filter: drop-shadow(0 1px 5px rgba(255, 255,255, 0));
}
.searchbar:hover {
filter: drop-shadow(0 1px 5px rgba(0, 0, 0, .1));
border: 1px solid white;
}
<div class="searchbar"></div>

Same css appears different in sketch and browser

I have a few divs one on top of the other that present a progress bar.
I got the css from sketch (graphic artist program).
In sketch the divs blend into each other, but when I take the css and put it in a html page it doesn't look as good.
Any idea what it can be?
I am attaching the css and screenshots:
.bar-bg {
width: 256px;
height: 10px;
opacity: 0.2;
border-radius: 5px;
box-shadow: inset 0 1px 6px 0 rgba(0, 0, 0, 0.9);
border: solid 1px $white;
background-color: $dark-blue;
}
.oval {
width: 24px;
height: 24px;
opacity: 0.9;
mix-blend-mode: color-dodge;
background-image: radial-gradient(circle at 52% 50%, #cf2d8e, #000000);
margin-top: -16px;
}
.progress {
height: 8px;
opacity: 0.9;
border-radius: 4px;
box-shadow: 0 0 6px 5px rgba(44, 146, 255, 0.7), inset 0 0 0 1px $icons;
border: solid 1px $blue;
background-color: $primary-1;
margin-top: -9px;
margin-left: 1px;
}
<div id="progressContainer">
<div id="bar" class="bar-bg"></div>
<div id="progress" class="progress" [style.width.px]="getProgress()"></div>
<div id="currentValue" class="oval" [style.margin-left.px]="getOvalLocation()"></div>
</div>
when I run it it looks like this:
trying to get it to look like this:
As you can see in image2 the divs blend into each other better than in image1.

Box-shadow inset & border:none cause form fields to flicker in IE/Edge

I have a problem on IE/Edge. I tried to solve it a couple day ago but I have no ideas. As I scrolled up and down my website, the form fields were flickering and flashing with white, grey and blue colors. I found out the issue, it was the box-shadow: inset 0 1px 3px 0 rgba(0,0,0,0.15) and border:0; . If I removed the inset attribute in box-shadow or border:0 in those input fields, then the form fields went back to the normal behavior. However, I want to keep those in the website. Not sure if there is any ways to work around this.
I attached the screenshot here
Codes:
input[type="text"],
input[type="email"],
input[type="number"] {
height: 4.2rem;
width: 100%;
max-width: 40rem;
background: $color_light_grey_1;
font-size: 1.4rem;
border: 0;
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.15);
border-radius: 3px;
padding: spacing(xxs) spacing(xs);
transition: box-shadow 0.2s, border-width 0.2s;
border-left: 0 solid var(--color-primary);
&:focus {
outline: 0;
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.15);
border-left-width: 3px;
}
#include breakpoint(xs) {
font-size: 1.6rem;
padding: spacing(xxs) spacing(sm);
}
&.input--alternate {
background: $color_white;
box-shadow: $light_shadow;
&:focus {
outline: 0;
box-shadow: 0 1px 1px $color_medium_grey_1;
}
}
}
In IE a property border-collapse: collapse; gets added automatically. try adding 'border-collapse: separate; to your input class.

Howto make an HTML box with shadow and pressable

I would like to make an HTML widget like this one:
https://jsfiddle.net/api/mdn/
.simple {
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
But I would like it to be pressable so that it flattens for 1 second and redirects to a different URL.
Edit:
I tried the following:
button {
width: 150px;
font-size: 1.1rem;
line-height: 2;
border-radius: 10px;
border: none;
background-image: linear-gradient(to bottom right, #777, #ddd);
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
button:focus, button:hover {
background-image: linear-gradient(to bottom right, #888, #eee);
}
button:active {
box-shadow: inset 2px 2px 1px black,
inset 2px 3px 5px rgba(0,0,0,0.3),
inset -2px -3px 5px rgba(255,255,255,0.5);
}
<button>Press me!</button>
https://jsfiddle.net/z7a0v8uv/
But I don't know how to translate the content of the button to make it look like it's being pressed down.
I found an answer here:
https://www.w3schools.com/howto/howto_css_animate_buttons.asp
I was looking for:
translateX(...) translateY(...)
As we can see in this working example:
https://jsfiddle.net/z7a0v8uv/1/
Now I just need to integrate this with the right style.
Edit:
Here is the complete CSS code:
button {
width: 100%;
border: none;
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
button:focus, button:hover {
background-image: linear-gradient(to bottom right, #888, #eee);
}
button:active {
box-shadow: 2px 2px 2px rgba(0,0,0,0.7);
transform: translateY(3px) translateX(3px);
}

jQuery click issue with a span styled to look like a button

Context
I've this buttons:
I detect when the user is clicking with jQuery .click().
But it works only if the user clicks on the text ("imdb" / "rottenTomatoes").
If the user clicks on the blue of button, jQuery detects nothing.
You can try on http://promobluray.fr.
Questions
What is the problem?
How to get this to work like a button?
Code
html:
<span class="rating">
<span class="rating-btn imdb active">imdb</span>
<span class="rating-btn rt">rottenTomatoes</span>
</span>​
css:
.rating {
padding: 14px;
}
.rating-btn {
display: inline-block;
margin-top: 24px;
padding: 4px;
position: relative;
font-family: 'Open Sans',sans-serif;
font-size: 12px;
text-decoration: none;
color: white;
cursor: pointer;
background-image: -o-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -moz-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -webkit-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -ms-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: linear-gradient(bottom,#2CA0CA 0,#08C 100%);
-webkit-box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
-moz-box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
border-radius: 5px;
}
.rating-btn::before {
background-color: #072239;
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
padding-left: 2px;
padding-right: 2px;
padding-bottom: 4px;
left: -2px;
top: 5px;
z-index: -1;
border-radius: 6px;
-webkit-box-shadow: 0 1px 0 #fff;
-moz-box-shadow: 0 1px 0 #fff;
box-shadow: 0 1px 0 #fff;
}
.active {
background: #2CA0CA;
-webkit-box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
-moz-box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
top: 7px;
cursor: default;
}
.imdb {
margin-right: 5px;
}
jquery:
$('.rating-btn').click(function() { ... });
​
You could try to increase the padding of the button so that the <span> matches the dimension of the image, but i think that the best solution is to change your markup and actually use <button>
It's seems to work in the latest versions of FF and IE, but not Chrome, Opera and Safari(win). I would suggest adding display:block; to .rating-btn styles to see what that does.
Alternatively, actually use buttons and style those how you want.
Use parent to attach handler
$('.rating:has(.rating-btn)').click(function() { ... });