Hover effect not working correctly in google chrome - css

I watched a video on Youtube about the hover effect, and I'm trying to do it by myself, but the problem is it's not working on google chrome: :before and :after background overflow when the transition executes.
In Firefox it works without any problem.
I thought it might be happening because I didn't use any prefixes, so I includes prefixes in code but the problem didn't go away
to be clear my problem
background of :before and :after show out of button border
body {
display: flex;
margin: 0;
padding: 0;
align-items: center;
justify-content: center;
height: 100vh;
}
a {
overflow: hidden;
display: block;
position: relative;
text-decoration: none;
color: #000;
border: 4px solid #000;
padding: 10px 30px;
font-size: 20px;
letter-spacing: 12px;
border-radius: 30px;
-webkit-border-radius: 30px;
text-transform: uppercase;
transition:color 1s ease-in-out;
transition-delay: 1s;
}
a:before {
content:'';
position: absolute;
top: 50%;
left: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,left,opacity;
transition-delay: 0s,1s,1.5s;
transition-duration: 1s,1s,0s;
}
a:hover:before {
border-radius:100%;
-webkit-border-radius:100%;
opacity:1;
left: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,left,transform;
transitiion-delay:0s,0.5s,2s;
transition-duration: 0s,0.5s,1s;
}
a:after {
content:'';
position: absolute;
top: 50%;
right: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,right,opacity;
transition-delay: 0s,1s,1.5s;
transition-duration: 1.5s,1s,0s;
}
a:hover:after {
opacity:1;
right: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,right,transform;
transitiion-delay:0s,0.5s,2s;
transition-duration: 0s,0.5s,1s;
}
a:hover{
color:#FFF;
}
Button

You have written transitiion instead of transition several times.
Your transition seems to be working (even if you do not say what you would like to do), it's just a little long.
You can play with the delay to change the duration of the animation, here is your code with shortened delays:
body {
display: flex;
margin: 0;
padding: 0;
align-items: center;
justify-content: center;
height: 100vh;
}
a {
overflow: hidden;
display: block;
position: relative;
text-decoration: none;
color: #000;
border: 4px solid #000;
padding: 10px 30px;
font-size: 20px;
letter-spacing: 12px;
border-radius: 30px;
-webkit-border-radius: 30px;
text-transform: uppercase;
transition:color .2s ease-in-out;
transition-delay: .1s;
}
a:before {
content:'';
position: absolute;
top: 50%;
left: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,left,opacity;
transition-delay: 0s,.5s,.5s;
transition-duration: .5s,.5s,0s;
}
a:hover:before {
border-radius:100%;
-webkit-border-radius:100%;
opacity:1;
left: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,left,transform;
transition-delay:0s,0.2s,.2s;
transition-duration: 0s,0.2s,.2s;
}
a:after {
content:'';
position: absolute;
top: 50%;
right: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,right,opacity;
transition-delay: 0s,.2s,.2s;
transition-duration: .2s,.2s,0s;
}
a:hover:after {
opacity:1;
right: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,right,transform;
transition-delay:0s,0.2s,.2s;
transition-duration: 0s,0.2s,.2s;
}
a:hover{
color:#FFF;
}
Button

I'm not sure to understand your problem but if it is the absence of transition it could be because you have wrote transitiion-delay instead of transition-delay.
I have tried your code with Chrome and Firefox and didn't noticed a difference.
You can learn more about the need (or absence of need) for prefixes on this website : https://caniuse.com/#search=transform

Related

Strange outline around skewed pseudo element in button

I'm using a pseudo element in a button to achieve an angled border. But in some browsers and some zoom levels, if you look closely you'll see a faint outline around the pseudo element towards the right of the button on the left edge of the pseudo element.
Here is the fiddle: https://jsfiddle.net/jw1kfmsh/
.button {
position: relative;
padding: 0 20px;
height: 53px;
background-color: red;
border: 4px solid black;
border-right-width: 0;
color: white;
font-weight: 900;
font-size: 14px;
transition: all .425s ease;
text-decoration: none;
display: inline-flex;
align-items: center;
z-index: 1;
filter: blur(0);
}
.button::after {
position: absolute;
content: '';
right: -19px;
top: -4px;
height: 53px;
width: 38px;
background-color: red;
border: 4px solid black;
z-index: -1;
border-left: 0;
transform: skew(-31deg);
transition: all .425s ease;
backface-visibility: hidden;
}
Button Text
I would consider a different idea where you will not have the issue. Make the shape as only one element and rely on overflow to hide the non needed part.
.button {
position: relative;
display:inline-block;
padding: 0 40px 0 20px;
line-height: 53px;
border-left: 4px solid black;
color: white;
font-weight: 900;
font-size: 14px;
text-decoration: none;
overflow:hidden;
z-index: 0;
}
.button::after {
position: absolute;
content: '';
right:0;
top: 0;
left:-5px;
bottom:0;
background: red;
border: 4px solid black;
z-index: -1;
transform: skew(-31deg);
transform-origin:top;
}
Button Text

Transition not working on hover

I don't know but for some reasons, transition doesn't seem to be working. I am testing this Google Chrome.
[data-title] {
position: relative;
margin: 100px;
}
[data-title]:hover:before {
transform: translate(-50%, 0);
width: 18px;
height: 6px;
left: 50%;
margin-top: 0px;
top: 100%;
opacity: 1;
pointer-events: auto;
-webkit-transition: all 0.25s;
transition: all 0.25s;
content: '';
position: absolute;
z-index: 10;
box-sizing: border-box;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #00204e;
}
[data-title]:hover:after {
transform: translate(-50%, 0);
left: calc(50%);
margin-top: 10px;
top: 100%;
opacity: 1;
pointer-events: auto;
-webkit-transition: all 0.25s;
transition: all 0.25s;
font-weight: normal;
text-shadow: none;
background: #00204e;
border-radius: 4px;
color: #fff;
content: attr(data-title);
padding: 10px;
position: absolute;
white-space: normal;
width: max-content;
font-size: 12px;
font-family: 'Helvetica Neue';
line-height: normal;
max-width: 150px;
text-align: left;
height: auto;
display: inline-block;
}
<span class="dijitButtonContents" id="saveButton" data-title="Save as draft"><span id="saveButton_label">Save</span></span>
Can anyone help where I am going wrong or am I missing something?
I have even tried to make transition timing to +1 seconds but still it doesn't reflects the same.
You have not set anything for the original state so the transition doesn't know what to go from. If you are only wanting to transition the item's appearance - eg fade in or out, then you need to do something like transition the opacity:
[data-title] {
position: relative;
margin: 100px;
}
[data-title]:before {
width: 18px;
height: 6px;
left: 50%;
margin-top: 0px;
top: 100%;
opacity: 1;
content: '';
position: absolute;
z-index: 10;
box-sizing: border-box;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #00204e;
transform: translate(-50%, 0);
opacity: 0;
transition: opacity 0.5s;
pointer-events: none;
}
[data-title]:after {
transform: translate(-50%, 0);
left: calc(50%);
margin-top: 10px;
top: 100%;
opacity: 1;
font-weight: normal;
text-shadow: none;
background: #00204e;
border-radius: 4px;
color: #fff;
content: attr(data-title);
padding: 10px;
position: absolute;
white-space: normal;
width: max-content;
font-size: 12px;
font-family: 'Helvetica Neue';
line-height: normal;
max-width: 150px;
text-align: left;
height: auto;
display: inline-block;
opacity: 0;
transition: opacity 0.5s;
pointer-events: none;
}
[data-title]:hover:before,
[data-title]:hover:after {
opacity: 1;
pointer-events: auto;
}
<span class="dijitButtonContents" id="saveButton" data-title="Save as draft"><span id="saveButton_label">Save</span></span>
If you want something to transition from one state to another, you have to define both states. This means having a base-style and a :hover-style.
For example:
.test {
width: 100px;
height: 50px;
background: red;
transition: all 2s;
}
.test:hover {
height: 100px;
}
<div class="test">test</div>
This works, because there is an initial state for the height attribute. This however:
.test {
width: 100px;
background: red;
transition: all 2s;
}
.test:hover {
height: 300px;
}
<div class="test">test</div>
This will not work, because the browser doesn't have a specified height as an initial state.

CSS Tooltip - Conversion from SCSS not working

I am trying to get a CSS tooltip to work correctly which I found on the thoughtbot blog. The only changes that I have made to the code is to change from Scss to CSS, and simplify the html a touch. However, when in CSS, it doesnt work.
The original article can be found here, where there is also a working codepen that I copied as the basis for my CSS version https://robots.thoughtbot.com/you-don-t-need-javascript-for-that
.container {
margin-top: 100px;
margin-left: 100px;
border: 2px solid red;
}
/* //The good stuff */
.tooltip-toggle {
cursor: pointer;
position: relative;
}
/* //Tooltip text container */
.tooltip-toggle::before {
position: absolute;
top: -80px;
left: -80px;
background-color: #2B222A;
border-radius: 5px;
color: #fff;
content: attr(data-tooltip);
padding: 1rem;
text-transform: none;
transition: all 0.5s ease;
width: 160px;
}
/*
//Tooltip arrow */
.tooltip-toggle::after {
position: absolute;
top: -12px;
left: 9px;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #2B222A;
content: " ";
font-size: 0;
line-height: 0;
margin-left: -5px;
width: 0;
}
.tooltip-toggle::before {
color: #efefef;
font-family: monospace;
font-size: 16px;
opacity: 0;
pointer-events: none;
text-align: center;
}
.tooltip-toggle::after {
color: #efefef;
font-family: monospace;
font-size: 16px;
opacity: 0;
pointer-events: none;
text-align: center;
}
/* //Triggering the transition */
.tooltip-toogle:hover::before {
opacity: 1;
transition: all 0.75s ease;
}
.tooltip-toggle:hover::after {
opacity: 1;
transition: all 0.75s ease;
}
Below is my html.
<html>
<body>
<div class="container tooltip-toggle" data-tooltip="Sample text for your tooltip!>
<div class="label">Hello
</div>
</div>
</body>
</html>
So, I laughed very hard when I figured your problem out:
/* //Triggering the transition */
.tooltip-toogle:hover::before {
opacity: 1;
transition: all 0.75s ease;
}
.tooltip-toogle:hover
Obviously should be toggle, lol.
Edit: cleaned css and fixed it
.container {
margin-top: 100px;
margin-left: 100px;
border: 2px solid red;
}
/* The good stuff */
.tooltip-toggle {
cursor: pointer;
position: relative;
}
/* Tooltip text container */
.tooltip-toggle::before {
position: absolute;
top: -80px;
left: -80px;
background-color: #2B222A;
border-radius: 5px;
color: #fff;
content: attr(data-tooltip);
padding: 1rem;
text-transform: none;
transition: all 0.5s ease;
width: 160px;
}
/* Tooltip arrow */
.tooltip-toggle::after {
position: absolute;
top: -12px;
left: 9px;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #2B222A;
content: " ";
font-size: 0;
line-height: 0;
margin-left: -5px;
width: 0;
}
.tooltip-toggle::before, .tooltip-toggle::after {
color: #efefef;
font-family: monospace;
font-size: 16px;
opacity: 0;
pointer-events: none;
text-align: center;
}
/* Triggering the transition */
.tooltip-toogle:hover::before, .tooltip-toggle:hover::after {
opacity: 1;
transition: all 0.75s ease;
}

Show div on hover : div didn't show on hover

I have this code :
#banner {-webkit-border-top-left-radius: 100px; -webkit-border-top-right-radius: 100px; -moz-border-radius-topleft: 100px; -moz-border-radius-topright: 100px; border-top-left-radius: 100px; border-top-right-radius: 100px; position:relative;}
#submenu { color: #fff; margin: 0 2%; position: relative; bottom: -0px; text-align: center; font-family: Oswald; font-weight: 700; font-size: 15px; padding:3px; z-index:1; visibility:hidden; opacity:0; -webkit-transition:300ms; -moz-transition:300ms; -o-transition:300ms; transition:300ms; }
#banner:hover #submenu { visibility:visible; opacity:1; }
And when I hover the #banner ID, the #submenu won't show. Is there something I'm doing wrong?
Thanks for your help.
EDIT : Here's the HTML code, if necessary :
<div id="banner"><div id="submenu">foo</div></div>
Check this: http://jsfiddle.net/4mcz0axk/
Div is showing up but the text of the color is white so it might not be visible.
In the fiddle shared, I intentionally changed it to black and it is working perfectly fine.
#banner {
-webkit-border-top-left-radius: 100px;
-webkit-border-top-right-radius: 100px;
-moz-border-radius-topleft: 100px;
-moz-border-radius-topright: 100px;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
position: relative;
}
#submenu {
color: black;
margin: 0 2%;
position: relative;
bottom: -0px;
text-align: center;
font-family: Oswald;
font-weight: 700;
font-size: 15px;
padding: 3px;
z-index: 1;
visibility: hidden;
opacity: 0;
-webkit-transition: 300ms;
-moz-transition: 300ms;
-o-transition: 300ms;
transition: 300ms;
}
#banner:hover #submenu {
visibility: visible;
opacity: 1;
}

Why are my absolutely positioned elements in different places on depending on browser/devices?

I have about 6 divs that I set to position: absolute.
After reading other threads, I made sure the parent element was set to position: relative,
Still for some reason the vertical positioning of these elements differ depending on browser/device.
For example, the positioning looks okay on chrome for macbook.
But it is off on Safari for Macbook, Safari on iPad as well as Chrome and IE for Windows.
http://codepen.io/donnaloia/pen/WbYbLa
It is the suggestion divs (in light gray), that are not positioning correctly.
What am I doing wrong here? Why is this happening?
.backgroundiv {
background-image: url(/static/img/bg-hero.jpg);
width: 100%;
position: relative;
padding-top: 25px;
height: 986px;
}
.background2div {
background-color: black;
background-repeat: repeat;
height: 800px;
position: relative;
}
.linecontainer {
width: 486px;
display: inline-block;
margin-left: 68px;
}
.formdiv {
padding-top: 50px;
float: center;
background-color: white;
height: 845px;
margin: 0 auto;
border-radius: 3px;
width: 632px;
position: relative;
}
.selltitle {
font-family: futura;
font-size: 28px;
text-align: center;
padding-bottom: 50px;
}
.forminput {
float:right;
margin-bottom: 32px;
}
.forminput input {
padding-top: .5em;
padding-bottom: .5em;
width: 230px;
}
.forminput submit {
padding-top: .5em;
}
.forminput2 {
float:right;
width: 232px;
margin-bottom: 32px;
}
textarea {
padding: .5em;
width: 221px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.checkmark1{
top: 228px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmarkimg {
width:20px;
}
.checkmark2{
top:285px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark3{
top:462px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark4{
top:545px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark5{
top:603px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
input.parsley-success,
select.parsley-success,
textarea.parsley-success {
color: #468847;
background-color: #DFF0D8;
border: 1px solid #D6E9C6;
}
input.parsley-error,
select.parsley-error,
textarea.parsley-error {
color: #B94A48;
background-color: #F2DEDE;
border: 1px solid #EED3D7;
}
.inputholder.parsley-success.checkmarksuccess {
display: block;
width:26px;
height:24px;
position:absolute;
}
.parsley-errors-list {
margin: 2px 0 3px 0;
padding: 0;
list-style-type: none;
font-size: 0.9em;
line-height: 0.9em;
opacity: 0;
position: absolute;
padding-top: 6px;
font-size:14px;
-moz-opacity: 0;
-webkit-opacity: 0;
transition: all .3s ease-in;
-o-transition: all .3s ease-in;
-ms-transition: all .3s ease-in;
-moz-transition: all .3s ease-in;
-webkit-transition: all .3s ease-in;
}
.parsley-errors-list.filled {
opacity: .5;
}
.suggest1{
opacity: .45;
margin-left:68px;
position:absolute;
top:153px;
font-style: italic;
}
.suggest2{
opacity: .45;
margin-left:68px;
width:150px;
position:absolute;
top:202px;
font-style: italic;
}
.suggest3{
opacity: .45;
margin-left:68px;
position:absolute;
top:297px;
font-style: italic;
}
.suggest4{
opacity: .45;
margin-left:68px;
position:absolute;
top:344px;
font-style: italic;
}
.suggest5{
opacity: .45;
margin-left:68px;
position:absolute;
top:392px;
width:132px;
font-style: italic;
}
.suggest6{
opacity: .45;
margin-left:68px;
position:absolute;
top:440px;
width:132px;
font-style: italic;
}
.suggest7{
color: red;
opacity: .75;
margin-left:325px;
position:absolute;
top:252px;
width:132px;
font-size:14px;
}
.suggest8{
opacity: .45;
margin-left:68px;
position:absolute;
top:489px;
width:132px;
font-style: italic;
}

Resources