How can I remove this stubborn blue outline (<a> element) from iOS browsers (Safari & Chrome)? - ios

I'm using Tailwind CSS and React.
I've tried about everything under the sun to try and remove this blue outline from my <a>-elements in my page;
This blue outline keeps appearing whenever I chose a menupoint and refresh
My immediate thoughts came to :focus on the a-elements, so I've tried the following:
.tabList {
#apply mx-5 flex flex-row py-2;
a {
&:focus {
outline: transparent !important;
border: transparent !important;
box-shadow: 0 0 0 0 rgb(0 0 0 / 0%) !important;
-webkit-touch-callout: none;
user-select: none;
}
&:focus-within {
outline: transparent !important;
border: transparent !important;
box-shadow: 0 0 0 0 rgb(0 0 0 / 0%) !important;
-webkit-touch-callout: none;
user-select: none;
}
&:focus-visible {
outline: transparent !important;
border: transparent !important;
box-shadow: 0 0 0 0 rgb(0 0 0 / 0%) !important;
-webkit-touch-callout: none;
user-select: none;
}
}
}
I've tried about every focus pseudoclass I can think off to try and target iOS, to no avail. Thing is, everything works just fine and I can actually manipulate and remove the border on my local machine (using ngrok to cast the developement port to my iOS device) and it doesn't come back. But whenever I push the same code to development and production, the blue outline keeps coming back. I even tried making the outline a different color (it worked) and iOS is still forcing the thick blue outline over my custom color outline.
I can't think of any relevant -webkit- css-classes I can use either. Many are deprecated or just plain won't work.
Here's a snippet of the actual TSX:
<Tab.Group selectedIndex={getIndexOfSelecetedTopMenuItem(state)}>
<Tab.List className={styles.tabList}> // Actual class
{getToplevelMenuItems(state).map((item) => (
<Tab as="div" key={item.menuItemId} className="basis-1/3">
<ButtonTopCategory navigationModelUpdater={navigationModelUpdater} menuItem={item} />
</Tab>
))}
</Tab.List>
I'm of course keeping accessability in mind, but right now the blue outline is just plain interfering with the design of the page;
Choosing a different (I've chosen the second point here) menupoint still keeps the first on in focus even after refreshing the page
If anybody has experiences with this (I've Googled my ass off), help would be appreciated. Thanks!
I've tried several tested and tried methods to no avail; removing the outline (setting the value to 0 or none), making it transparent, changing the color (iOS forces the blue on it anyways), setting tabIndex prop to 0 or -1..
I expected the blue outline to go away when chosing 0 or none.
UPDATE UPDATE UPDATE
It turns out I was slaying the beast with the wrong tools. I'm using HeadlessUI for the tabs rendering, and it turns out I can use Tailwind CSS to apply styling conditionally. Whenever the tab was selected, I noticed the state of the Tab-component changed to "selected".
I looked up the Headless-UI docs and it turns out you can change the styling when the state changes. I applied "outline-none" as following to the Tab component;
<Tab as="div" key={item.menuItemId} className={"ui-selected: basis-1/3 outline-none"}>
Reference:
https://headlessui.com/react/tabs#using-data-attributes
Turns out the state was overriding the manual CSS!

I’m posting your work-around as an answer.
You should not do this without providing a reliable way to render Focus visible
It turns out I was slaying the beast with the wrong tools. I'm using HeadlessUI for the tabs rendering, and it turns out I can use Tailwind CSS to apply styling conditionally. Whenever the tab was selected, I noticed the state of the Tab-component changed to selected.
I looked up the Headless-UI docs and it turns out you can change the styling when the state changes. I applied outline-none as following to the Tab component;
<Tab as="div" key={item.menuItemId} className={"ui-selected: basis-1/3 outline-none"}>
Turns out the state was overriding the manual CSS!

Related

white input background on iphone, can't get it away

Is anyone familiar with a white background on an input on iPhone ?
I am trying to make an input without any styling, so with a transparent background.
Everywhere it works fine except on the iphone.
What I've tried already is
background: none;
background-color: none; or background-color: transparent; (tried both)
da
-webkit-appearance:none;
none seems to work. Anyone knows what the problem might be?
I tried it on an iPhone 6 with iOS 10, real device and simulator, using
<input style="background: transparent; border: none;" type="text" />
There doesn't seem to be a problem with that. The input is fully transparent.
Please check the inspector to see if any other style declaration is overwriting yours.
Do this in the "computed styles" section of the inspector and check the background or background-color property. It will tell you which declaration is used to render the element. You can jump directly into this declaration by using the little arrow, see the screenshot from chrome inspector
chrome inspector screenshot
Try to avoid using !important because this will mess up your code and it is not a good practice. Use better qualified selectors instead.
Use background: transparent!important; or apply id to the input field like:
input type="text" id="search">
Css:
input#search{
background: transparent;
}
The solution in this case was to put
all: revert !important;
before any other input styling. It probably got overwritten by something in the framework I use.

JQuery UI Dialog - unwanted space below dialog box

I'm working on a simple tic-tac-toe application and building it in CodePen. When the user loses or forces a draw (designed to be unbeatable), a jquery UI dialog box pops up informing the user of said result. Issue I'm having, is that when this happens, a large empty space appears causing a scroll bar to appear at the right of the page. This is a small detail - but I'd like to fix. I cannot put overflow: hidden on the body because then users won't be able to scroll on small screens or in resized browser windows. I've already tried the following to no avail:
adjusting position of dialog to very top of screen
putting overflow: hidden rule just on .ui-dialog
adjusting the height of the dialog box
adjusting the margin-bottom of .ui-dialog
messing with other dialog options to see if they were the cause
Some of these seemed far-fetched but I wanted to try everything I could think of before coming here. Research has turned nothing up either. I'm running Chrome and the pen in question can be found here: http://codepen.io/no_stack_dub_sack/pen/YGNRxO.
Any help on this would be much appreciated! Thanks in advance.
Again, this is a small detail, but since the app fits all on one page without scroll on most screens, I'd like to keep it looking as clean as possible.
Here's the code:
// DIALOG BOXES
$('body').append('<div id="draw" class="gameOver"><p>It\'s a Draw!</p></div>');
$('body').append('<div id="loser" class="gameOver"><p>You Lose!</p></div>');
$('.gameOver').dialog({
autoOpen: false,
resizable: false,
height: 120,
dialogClass: 'no-close',
buttons: {
'Play Again?': function() {
$('.gameOver').dialog('close');
setNewGame();
}
}
});
Somewhere in the dialog creation process, the position is set to relative on your dialog, which causes the height of your game to calculate the dialog, which gives the empty gap. You can simply set ui-dialog position to absolute in the css, and it'll solve the problem:
.ui-dialog {
position: absolute;
box-shadow: 1px 1px 30px 5px;
background: #04A777;
border-radius: 10px;
outline: none;
overflow: hidden;
margin-top: none;
}
http://codepen.io/anon/pen/EgmoGZ

Box shadow spread bug in WebKit in iOS 7 on Retina iPads

I've found what seems to be a bug in WebKit for iOS 7, but only on iPad 3 and 4, which leeds me to believe it's somehow hardware-related.
The bug: If I add the spread value (the fourth value) to CSS box shadows the whole shadow disappears. I've put up an exampel here.
Can anyone else confirm this error on iPad 3 and 4 with iOS 7?
Still an issue in IOS 7.0.4.
Add a one pixel border radius to force the browser to render the shadow in landscape mode and while zooming.
border-radius: 1px;
We've found a good rule of thumb when dealing with safari and/or iPad issues (or both). Put the following rule on the element or class to force hardware rendering.
transform: translate3d(0,0,0);
This solved my problem getting a shadow (used as a border with the spread value) to render on an iPad the same as other devices.
It is even more strange i was looking into the exact same problem.
If you use inset you can define your spread and then it is working fine!
an other fine fact is that your dropshadow will be gone as you turn your ipad into landscape mode.
This is a quite annoying bug!
I had a similar issue on iPad mini w/ iOs 7.0.3
the problem appeared both in safari and in chrome
input field with inset box shadow didn't appear at all regardless the zoom
div drop shadow appeared, but when zoomed in changed to a line and further zoom in hide the line as well.
I found on another thread this solution:
"Try adding -webkit-appearance: none;, because iOS tends to mess up forms."
and it solved the problems !
Something similar here. Applied box-shadow to image elements. It shows fine at zoom=1. But if you zoom in, it disappears on iPad 3 with iOS 7.
CSS Code used:
#photostrip > img {
-webkit-box-shadow: 0px 6px 8px rgba(0,0,0,0.33);
-moz-box-shadow: 0px 6px 8px rgba(0,0,0,0.33);
box-shadow: 0px 6px 8px rgba(0,0,0,0.33);
}
Same issue with iPad Air / iOS 7 :(
Setting -webkit-appearance didn't help, neither did border-radius.
I used the following CSS to fix it (it lets you use the spread setting on other browsers, and overrides for webkit/iOS only):
.box_shadowed
{
box-shadow: 2px 2px 4px 2px #ccc;
-webkit-box-shadow: 2px 2px 4px #ccc;
}
I had the same issue on iPad 4 with iOS7. When I set CSS box shadow for an element it appears as intended on iPad portrait view. But when I rotate the iPad to landscape view the box shadow gets disappear.
I tried StrandedPirate's solution - adding 1px border radius to the element and it worked! This solution might not be applicable for all cases, but for my case it is adoptable.
I had the same problem and added border-radius:1px to fix it.
I was using:
border-radius: 100%;
box-shadow: 0 0 0 20000px rgba(255,255,255, .6);
and the shadow wasn't appearing on iPad(iOS 11): Safari and Chrome.
I tried all the other answers but with no luck.
The solution for me was to reduce the spread from 20000px to 922px. This was the max value that I could use so the shadow would appear.
One single rule didn't helped in my case.
At the end I fixed adding ALL these rules:
-webkit-appearance: none;
border:0;
border-radius: 1px;
height: 1px;
In particular setting also the height.

z-index not properly rendered on iPad and Google Chrome 22

I have attached two pictures, the first shows the "desktop" of the webapp I work on, some of the icons you see open dialogs made of a <div/> containing an <iframe/>, but while on a normal pc it all works properly, on the iPad it seems there is a problem with the z-index of some elements, as shown in second picture.
The small red rounds with number inside are defined as follows:
.countComunicazioni {
position: relative;
background: url(/images/admin/menu_sgs/counter.gif) no-repeat center center;
height: 35px;
width: 35px;
color: #FFF;
top: -105px;
left: 120px;
z-index: 0;
font-weight: bold;
display: none;
}
.countComunicazioni p {
margin-top: -5px;
padding-top: 10px;
}
The markup is a <div class="countComunicazioni"/> tag and a <p/> tag inside.
I also noticed that now the problem also appears in Google Chrome V22, the numbers in red circles are always on top even if they have z-index == 0 and the dialogs have z-index > 1000.
As per this bug report ( http://code.google.com/p/chromium/issues/detail?id=144518 ), the change seems to be intended, even if I would bet it'll broke many layouts, not only ours.
This problem was not present in previous versions of Google Chrome, nor is present on Firefox V15 or Internet Explorer V9, where everything is rendered problem.
How can this problem be solved? I'm no CSS expert, so I must admit I have tried little, if anything, so far... And also, who is "right" here? Is our markup incorrect, or does the problem lie in google chrome new rendering strategy?
EDIT
It seems I've been able to solve the issue shown in the two pics: all the dialogs generated from my web app are placed inside a <div/> with position:fixed placed on the very top of the body, now I tried to move the div to the very bottom of the page, and the layout seems now correct.
There is one more problem though: when opening a modal dialog, the opaque layer that is supposed to be created between the dialog and the below content, is actually created above it, see new screenshot.
How could this problem be solved? Does it require modifying our javascript or is it an issue with jquery ui itself?
Just found out myself that the way that chrome 22+ handles z-index has been altered.
Check out this awesome explanation here that I didn't write here...
http://updates.html5rocks.com/2012/09/Stacking-Changes-Coming-to-position-fixed-elements
Basically the way I understand it is that elements which have
position: fixed
now get counted with their own z-index layer so you'll have to adjust your pages accordingly to suit.
Hope that helps!

jquerymobile button clicked goes blue

I'm trying to prevent my button from flashing blue after clicking, anyone know what class causes this change? so I can override it
Cheers!
For anyone landing here and wondering what to do with .ui-btn-active, I'd like to build on sqlisers answer with:
.ui-btn-active
{
color: #2F3E46 !important;
background: none !important;
background-color: #eee !important;
text-shadow: 0 /*{a-bup-shadow-x}*/
1px /*{a-bup-shadow-y}*/
0 /*{a-bup-shadow-radius}*/
#ffffff /*{a-bup-shadow-color}*/;
}
Just change the color values to whatever you like.
If this happens on your mobile, I'd suggest adding this to your stylesheet:
* {
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
This will remove the default tap-highlight function of the webkit browser (on any mobile). Seems to work mostly on Android phones, but it does have affect on iOS devices as well.
The class you're looking for is
.ui-btn-active

Resources