Position of Button Changes on Hover in Safari - html

My goal is to make a circular icon button wherein a single icon is enveloped by a circle, and the circle shrinks on hover, but the icon stays centered.
I got this effect working in Firefox and Chrome, but in Safari 9 (I assume it's similar in Safari 10), when I hover over the buttons, their vertical position occasionally moves up and down unexpectedly. It seems to mostly occur when rapidly changing which button is being hovered.
This is the HTML structure of the button:
<a class='icon-button'>
<button>
<span class='bg'></span>
<span class='icon'>A</span>
</button>
</a>
This is the SCSS code I am applying:
.icon-button {
$width: 2em;
display: inline-block;
width: $width;
height: $width;
overflow: hidden;
cursor: pointer;
button {
position: relative;
display: flex;
align-items: center;
text-align: center;
width: $width;
height: $width;
padding: 0;
margin: 0;
background: none;
border: none;
cursor: pointer;
}
.bg {
background-color: #FF9999;
width: $width;
height: $width;
border-radius: $width / 2;
margin: 0 auto;
transition: width 128ms linear, height 128ms linear;
}
&:hover .bg {
width: 0.8 * $width;
height: 0.8 * $width;
}
.icon {
color: #FFF;
position: absolute;
top: 0;
left: 0;
line-height: $width;
width: 100%;
}
}
Here is a JSFiddle page where I replicated the issue with the relevant code: https://jsfiddle.net/Auroratide/6u463jL5/3/
Does anyone know what is causing this to happen in Safari but not the other browsers? I'm probably going to need to change my strategy so the CSS is not as jank, but I'm curious nonetheless.
UPDATE:
Here a link to a video of what I am seeing, contrasting Firefox with Safari:
http://tarm.wdfiles.com/local--files/files/safari_jankiness.mov

Try adding
-webkit-transition: width 128ms linear, height 128ms linear;
The -webkit- refers to browsers such as Chrome and Safari, so will hopefully fix the problem you're experiencing.

It seems that the below CSS fixes this:
.icon-button {
position: relative;
}
.icon-button button {
position: absolute;
top: 0; left: 0;
}
I'm still not really sure what was going on in Safari, but it seems to have been a positioning issue relative to the size of adjacent elements (I had noticed the issue does not arise on a button in isolation). Absolute positioning guarantees the elements are positioned based solely on the parent, so I'm guessing that's why this fixes the issue.

Related

Position fixed being cut off on safari

I have a fixed position tooltip that works in all browsers except Safari. In safari, the tooltip is being cut off by the parent's container which has properties of overflow: scroll
Any ideas on how I can fix this?
This is the screenshot of how it's supposed to look like:
This is how it looks on safari:
These are the properties for the tooltip:
.announcement {
position: fixed;
width: 3.1rem;
height: 3.1rem;
background-image: url("./../assets/icons/announcement-alert-right.svg");
background-size: cover;
margin: 0 0 0 -2.8rem;
z-index: 1;
&:hover {
margin: -3.6rem 0 0 -14.8rem;
width: 15.3rem;
height: 6.7rem;
background-image: url("./../assets/icons/announcement-profile.svg");
}
#media screen and (max-width: $desktop) {
display: none;
}
}
This is the parent's perspective:
.profile {
position: fixed;
z-index: map-get($zindex, sidebar);
right: 0;
width: 15%;
height: 100%;
transition: 0.5s;
padding: 3rem;
box-shadow: 0 1.5rem 3rem $color-shadow;
background-color: $color-white;
overflow: scroll;
-ms-overflow-style: none;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
I've tried several different fixes such as:
-webkit-transform: translateZ(0); transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0); z-index:9999 !important) and none of them works.
Any help would be much appreciated!
Thanks!
Without knowing your html code i speculated that the parent container and the tool tip element are not at the same level so even if you increase z-index value it won't change.
Place the element at the same level that would work.Something like this
<parent-container>
//parent content
</parent-container>
<tooltip-element>
//tooltip-content
</tooltip-element> //same level
Check the parents' properties and the overlapping element's properties. Some of them has a position or a z index value that is blocking it from your desired behavior
I bet is that maybe you will need to split up the position: fixed and overflow tags across two nested div classes in Safari? I know this could be a bit annoying and inconvenient, but then that way - I don't think that the z-index will be blocked off...
HTML:
<div class="wrapper1">
<div class="wrapper2">
<div class="inner">
/* Stuff inside here */
</div>
</div>
</div>
CSS:
.wrapper {
...
position: fixed;
...
}
.wrapper2 {
...
overflow: hidden;
position: absolute;
...
}
I wouldn't have thought that the overflow: scroll would affect any of the z-index properties but we'll see. Good luck on finding a solution, hopefully I've somewhat helped!

Css, unwanted Horizontal scroll on mobile

I came across a small problem, for some reason I see a huge white gap in the left of the <html> tag
I tried to add the HTML and body tag this rules:
overflow-x: hidden;
max-width: 100vw;
It works on desktop view (even if I resize the browser window)
but it didn't help in mobile (it didn't help in mobile view in chrome dev tools).
What can be the problem?
I think it has something to do with it that the site css is mainly using flexbox.
as well I suspect it has something to do with the div marked in red in the picture (which is position fixed but for some reason appears after scrolling down).
This is that div css rule
.contact-mobile{
position: fixed !important;
display: flex;
flex-wrap: nowrap;
justify-content: space-around;
padding: 15px;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
max-width: 100vw;
background-color: $black;
opacity: 0.9;
a{
min-width: 25%;
text-align: center;
padding: 5px;
i{
color: #fff;
}
&:hover{
opacity: 1;
i{
color: $black;
}
background-color: $green;
}
}
}
this is the dev site http://davdev.co.il/broker
this is a zoom out of what I see
https://www.screencast.com/t/P7zQwdWySBv
The problem come from your iframe position,
Put top: -5000px instead of left: -5000px, and it will fix the gap on mobile

Div disappears on hover in IE

I'm not sure what's going on here. In Firefox and Chrome, this works as it should, but not in IE. I have a fixed div (firstdiv) that reveals another div (hiddendiv) upon hover. And that div should remain visible as long as either div is being hovered on. However, in IE it's disappearing when you hover over it. Why is this?
I've tried experimenting with different z-index values and positioning, but I can't see why IE isn't handling this properly.
.firstdiv {
background: red;
position: fixed;
left: 10px;
bottom: 10px;
height: 50px;
width: 50px;
cursor: pointer;
z-index: 1110;
}
.hiddendiv {
background: blue;
position: fixed;
bottom: 60px;
height: 40px;
width: 244px;
display: none;
cursor: pointer;
z-index: 1200;
}
.firstdiv:hover + .hiddendiv {
display: block;
cursor: pointer;
}
.hiddendiv:hover {
display: block;
cursor: pointer;
}
<div class="firstdiv"></div>
<div class="hiddendiv"></div>
When I check in IE, it is working fine.
Not sure which version you are using. Not sure your actual code is the same as the example code you provided here.
Anyways, The below code may help you.
.firstdiv:hover + .hiddendiv:hover {
display: block;
cursor: pointer;
}
It turns out this was caused by Internet Explorer being in Compatibility View for this site.

Image getting clipped inside circle and re-positioning after scaling

I want to display images as circle on my webpage. For that, I have an image set as background wrapped inside a div container. Both the divs (outer and inner) have been given a border radius of 50% to achieve this. I also want the image to zoom in oh hover, for which I have applied transform:scale on the inner div.
The image is getting clipped a bit from left and right sides so it doesn't appear as a perfect circle. However, when the image gets scaled up on hover, the image forms a perfect circle. I have tried re-positioning it with background position, tried using a bigger image, increased/decreased size of both divs, but no method is working.
Further, when the image gets zoomed in on hover (using transform:scale), it gets re-positioned slightly after the transformation is complete. Strangely, if I remove the transition effect (transition duration and transition-timing-function), then this re-positioning doesn't happen.
Can anybody figure out why this is happening and what is the solution?
I am using bootstrap (I know it has a class img-circle which draws circle, but I wish to use my own code).
You can see the code running here: http://jsfiddle.net/dk49/h9KZr/
Observe the clipping of image on left and right sides of the circle and how it gets into correct shape on hovering over it. You can also see the jittering of image on zooming when hovering over it.
<div class="container-fluid page-content-wrapper">
<div class="col-xs-12 col-sm-4">
<div class="circle-container">
<h2 class="img-header">Men</h2>
<div class="inner-circle img-men"></div>
</div>
</div>
</div>
CSS:
.page-content-wrapper {
max-width: 980px;
margin-left: auto;
margin-right: auto;
background-color: #000;
}
.circle-container {
max-width: 325px;
max-height:325px;
border-radius: 50%;
overflow: hidden;
position: relative;
margin: 20px auto 0 auto;
z-index: 5; /* for fixing chrome bug */
}
.inner-circle {
width: 100%;
height: 100%;
padding-bottom: 100%;
border-radius: 50%;
overflow: hidden;
position: relative;
transition: transform 0.15s ease-in-out;
}
.inner-circle:hover, .inner-circle:active {
transform: scale(1.1);
}
.circle-container:hover .img-header, .circle-container:active .img-header{
bottom: 30%;
background-color: rgba(255,255,255,0.9);
}
.img-header {
color: #fff;
bottom: 10%;
position: absolute;
width: 100%;
color: #000;
background-color: rgba(255,255,255,0.7);
font-size: 25px;
font-weight: 500;
padding: 7px;
text-align: center;
height: 43px;
vertical-align: middle;
z-index: 1;
transition: bottom 0.15s ease-in-out, background-color 0.15s ease-in-out;
}
.img-header:hover ~ .inner-circle, .img-header:active ~ .inner-circle {
transform: scale(1.1);
}
.img-men {
background: url(http://s8.postimg.org/qohfig4md/men.png) center center no-repeat;
background-size: contain;
}

Drop down menu going under #main div background in IE 7/8/9

Here is the link to the domain http://linenwoods.com I am working on. I am going to fit the navigation list items on the header, but when the drop down menu is implemented I'm pretty sure it'll go under the #main div like you see currently. Is there any easy way fix to this? I couldn't find anything related to this from a google search .. was hoping someone could help me out. Below is the relevant CSS .. I tried playing around with z-index with no luck as I was told IE8 renders it strangely. If you have the time please follow the link with IE and leave a response .. I am trying to be as cross-browser compatible as possible and already am at a pretty pathetic start. Any help would be appreciated :)
body {
background-image:url('Background1.jpg');
background-position: center;
height: 100%;
margin: 0;
padding: 0;
opacity: 0.8;
filter: alpha(opacity=80);
}
#main {
width : 1010px;
height: 1315px;
background-color: white;
margin-top: 15px;
filter: alpha(opacity=80);
}
header {
width: 1010px;
height: 230px;
background-color: white;
margin: 0 auto;
margin-top: 15px;
filter: alpha(opacity=80);
}
footer {
width: 1010px;
height: 230px;
background-color: white;
margin: 15px 0 15px 0;
filter: alpha(opacity=80);
}
Apply this CSS (works only in IE8 and 9):
ul.nav {
position: relative;
z-index: 2; /* 2 or higher */
}
IE7 does... weird things with the z-index. If you want to target IE7 as well, you can do this (CSS hack taken from this page):
ul.nav {
position: relative;
position: absolute !ie7; /* For IE7 only */
z-index: 2; /* 2 or higher */
}
Using z-index only works on positioned elements. When you tested zindex stuff, were your elements either absolute or relative?