CSS with JQueryUI autocomplete across browsers - css

I'm fairly inexperienced with CSS across Browsers, so apologies if this is simple or obvious.
I have a Leaflet map with a JQueryUI Autocomplete/Combobox search functionality. Everything is working just fine. I have it looking as I want it in Chrome.
If I take a look at the combobox in Safari or Firefox it's off by a pixel or so (the button on the side is either one or two pixels above or below the input box). And as you can see in the screen shots, it doesn't look good at all. Below is the CSS code and screen shots.
My question is: what CSS properties should I be playing with to get the combobox aligned across browsers? Is there a website that will describe the cross-browser inconsistencies so I can be aware of them?
Current CSS related to Combobox:
.custom-combobox {
position: relative;
display: inline-block;
margin: 2px;
}
.custom-combobox-toggle {
position: absolute;
top: -1px;
bottom: 0;
margin-left: -1px;
padding: 0;
/* support: IE7 */
*height: 1.7em;
*top: 0.1em;
}
.custom-combobox-input {
margin: 0;
padding: 0.3em;
width: 140px;
}
.custom-combobox .ui-button-text {
height: 14px;
}
Chrome Version (looks good):
Firefox Version (looks off):
Safari Version (also off):

Got it working. The culprits were:
em sizing - apparently Chrome and Firefox have different ideas of how big an Em is with the same font
position relative vs absolute - the relative positioning of the .custom-combobox class was screwing up the positioning when compared side by side. I imagine Chrome and Firefox have slightly different values they position off of for relative positioning.

Related

align-self:flex-end and margin-bottom: xpx not working as expected in Safari and iOS devices

I'm having some issues with iOS ignoring a combo of align-self:flex-end and margin-bottom: 8px.
On Android devices, various Windows versions with Chrome and Firefox, and Chrome on macOS, #totalImg is displayed as I'd expect it to be - bottom right corner, slightly raised.
On Safri for macOS and Safari and Chrome for iOS, #totalImg is glued to the bottom.
See the following image for current behaviour:
I'm aware that I could get consistent cross-browser behaviour by applying bottom: 8px, but that seems to be working just in my test case, and fails in production, depending on the screen width of Android or iOS devices. For example, on Chrome for Android, with bottom: 8px, #totalImages can end up in the middle of its parent div, or well below it.
.image.big.j_launch {
display: flex;
display: -webkit-flex;
}
.image.big {
width: auto;
height: auto;
max-width: 320px;
margin-bottom: 10px;
float: none;
position: relative;
}
#totalImg {
display: block;
height: 15px;
position: absolute;
right: 11px;
background-color: rgba(0, 0, 0, 0.35);
padding: 2px 6px;
border-radius: 3px;
color: white;
font-size: 11px;
text-align: center;
align-self: flex-end;
margin-bottom: 8px;
}
<div class="image big j_launch" data-index="0">
<div id="totalImg"><span>1 / 18</span></div>
<img src="https://via.placeholder.com/320x240">
</div>
How can I get a consistent crossbrowser solution, which would place #totalImg as it's currently placed in the first image? Is there a reason for Safari (and iOS in general) to ignore what seems to be working on other platforms / browsers?
Looking at the document inspector in Safari, I can see that the margin is applied - there's an orange rectangle below #totalImg, which keeps growing / extending itself downwards, when I'm changing the margin-bottom value in the stylesheet inspector. It's just not being applied visually as I'd expect it to be.
While this is a solution, is not the best solution, and I'd recommend against it, even though it works.
First, a little bit of JavaScript is needed (as seen on this link).
var b = document.documentElement;
b.setAttribute('data-useragent', navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
What this block does is that it adds two data attributes to the document itself (and a touch class if it's a handheld device). In my case - iPhone and Mac - data-platform had values of iPhone and MacIntel, respectively. classname and data-useragent are unnecessary in this context, but were not removed from the original code for illustrative purposes.
Next, add some new rules to CSS.
html[data-platform*='Mac'] #totalImg,
html[data-platform*='iPhone'] #totalImg {
bottom: 8px !important;
margin-bottom: unset !important;
}
This relies on partial macthings by the platform, and adjusts the rules accordingly - since bottom was recognized and applied on *OS devices, and margin-bottom was not, the rules are changed.
The reason I dislike this is that looks like a Rube Goldberg machine, and it's overly complicated for something that should've been solved in CSS alone.
Not to mention that it relies on a deprecated / obsolete feature.

CSS only modal window OK on Android, not working on iOS

I've got some CSS code in order to display the title attribute when touching on abbreviations and symbols of a smartphone's screen. Within a section '#media only screen and (max-width: 767px)' of my stylesheet I have the following code:
span[title]:active::after,abbr:active::after {
color: Maroon;
font-weight: bold;
content: 'Meaning: ' attr(title);
position: fixed;
top: 3ex;
left: 2ex;
display: block;
z-index: 100;
background-color: White;
box-shadow: .3ex .3ex .1ex Grey;
border: 1px solid grey;
padding: .4ex;
width: 70%;
height: auto;
}
It does work flawlessly on Android -I've tested it on Chrome, Firefox and Samsung browser- and my iMac -tested it on Chrome, Firefox, Safari and Opera after stretching the width of the browser's window, but it doesn't work on iOS at all! The trick/workaround of adding '-webkit-transform: translate3d (0,0,0);' added to the code did not help to this.
I should appreciate any help a lot!
Thank you very much indeed!
SOLVED!
I tried the solution as proposed in the following link: Enable CSS active pseudo styles in Mobile Safari
and it works fine. The problem was that Safari Mobile disables :active pseudo-class by default, and this simple idea solves it.
I tried some other working solutions, such as 'body ontouchstart=””' and similar ones, but all of them gave errors when checking the code against W3C validator.
Many thanks to all those that answered and tried to help!
The :active property only works on activabe elements. Documentation says:
There may be document language or implementation specific limits on which elements can become :active or acquire :focus.
So the most simple thing to do is to set the tabindex attribute to 0 for each element you want to be activable.
This has the big advantage that your code will work with keyboard.
EDIT: adding tabindex=-1 for all elements can be done easily with jQuery using
$("abbr[title]").attr("tabindex", -1);
or using standard javascript
var ele=document.querySelectorAll("abbr[title]");
for (var i=0;i<ele.length;i++) {
ele[i].setAttribute("tabindex", -1);
}

What ie-specific CSS do I need to add to my Wordpress site to fix this issue?

Here is how the site looks on Internet Explorer:
http://www.browserstack.com/screenshots/0c3c039e85f44bb70fddfc34b887b5bbc3357899
I've only seen it on the latest version of IE on Windows 8.1, but it's possible that it happens on older versions as well. Unfortunately, I'm on a Mac and can't find any emulators to run IE.. So I am coming to the greatest community of tech-savvy people I know of for help.
The site (built with Wordpress) is commercialpaintersinc.com. It looks great on Google Chrome and Safari.. so this issue seems to be just in IE (although I haven't tested in Firefox either..).
This is how it is supposed to look:
Anyone got any idea as to what CSS I entered that caused the issue and/or how I can fix it to make it look how it is supposed to on ALL browsers?
Any feedback is majorly appreciated. Thanks!
You are presently using negative margins to adjust layout, which is giving wildly different results in all three major rendering engines (Trident, Blink, and Gecko). I would advise against this, as it's likely these vendors will need to discuss whose approach is correct, or if all three need to adjust to be in better conformance with a fourth alternative.
The primary issue is is the over-hang of your logo beyond your negative margin. If you were to position the image absolutely, you could get more consistent results. However, upon doing so you will need to restore the layout of your header since a crucial element will no longer contribute to its dimensions.
#logo {
position: absolute;
}
#main-header {
min-height: 160px;
}
The above two rules appear to restore the layout for me in IE, and Firefox. That being said, I still think Chrome may be in the wrong here - you should always test your layout regularly in all three major browsers to ensure you aren't building on top of a browser bug.
I work on the Internet Explorer team, and have filed an issue internally for us to investigate this particular layout anomaly further. I've created a reduced demo of the issue as a public fiddle as well.
If you need to test Internet Explorer from a Mac in the future, please visit http://modern.ie.
Thank you all for the help. I was having a mental blockage and once again this community helped me to move forward.
Jonathan Sampson was correct that the root cause was that the CSS was not originally done correctly. I did the CSS edits myself and I am self-taught, so this was no surprise to me, haha. However, I had already come up with a solution.
My Solution:
I used the famous CSS Browser Selector script which can be found here: http://rafael.adm.br/css_browser_selector
I added it to my JS folder (mysite.com/wp-includes/js/css_browser_selector.js) and then added:
<script src="css_browser_selector.js" type="text/javascript"></script>
right before the </head> tag in the header.php file.
At that point I was able to just create browser-specific CSS. It's dumb that FF and IE are so picky when it originally worked fine how I had it in both Chrome and Safari... But oh well.
Here is the code for Chrome/Safari vs. the code for Firefox/IE:
Chrome/Safari (Webkit):
.webkit #logo {
margin-bottom: 10px;
max-height: 110px;
position: relative;
z-index: 99999;
background: #fff;
border-radius: 150px;
border: 20px solid #fff;
}
.webkit #main-header {
padding: 10px 0 0 0;
margin-bottom: -65px;
margin-top: -20px;
}
Firefox (and same used for IE as well):
.gecko .et_pb_slider {
top: -60px;
margin-bottom: -63px;
}
.gecko #logo {
margin-bottom: 10px;
max-height: 110px;
position: relative;
z-index: 99999 !important;
background: none repeat scroll 0% 0% #FFF;
border: 20px solid #FFF !important;
border-radius: 150px;
}
.gecko #main-header {
margin-top: -20px;
}
So yeah I didn't see Jon's answer until after I had "fixed" the issue. So, I will leave it as is.. although I'm sure my CSS is very sloppy! :P
Screenshot of IE browser now that it is fixed:
http://www.browserstack.com/screenshots/0d669a15d18040086fede2df90f134e526aef8f3
Thanks,
Chris

Padding Issues in Chrome vs Firefox

Having issues with aligning my button text across browsers. I've combed similar questions and have tried the suggestions but to no avail (display: inline-block for my hyperlinks, line-height: 1). There is too much headroom in firefox with my buttons (see homepage slider) and it looks just fine though in Chrome. Site is: jdd.meteor.com
*I was told this question was "off topic" when I tried to ask before. Please let me know what I can do to keep this question active if it is not on topic, whatever that means, so I can make changes.
Thanks!!
Screen captures (Chrome then Firefox):
#middle-section #slider .item .content hgroup a.call-to-action {
background: #820024;
color: white;
padding: 20px 30px;
letter-spacing: 0px;
font-size: 1.2em;
}
a {
color: #00aab5;
display: inline-block;
line-height: 1;
}
I had the same issue this morning, you need to define a height as well, that solved the problem for me, it looked great in Chrome but without height it looked squished in Firefox. Hope this helps.

Why is Safari ignoring my CSS position?

The problem is on this page: http://www.matternow.com/portfolio/
If you click on any of the thumbnails you'll see that the image title in the lower left of the overlay is too close to the border above it. This looks fine in Chrome (and all the other browsers, for that matter). Seems like it's ignoring my CSS for the element, which is set to be bottom: 0;
This is a browser hack, by the way. Looks like This:
#portfolio-overlay #cboxTitle{
font: bold 21px 'Crimson Text', serif !important;
position:absolute;
bottom: 8px;
top: auto;
left: 10px;
color:#000;
}
#media screen and(-webkit-min-device-pixel-ratio:0) {
#portfolio-overlay #cboxTitle {
bottom: 0;
}
}
Anyone know why this is happening? I mean, since it looks good in Chrome it SHOULD look good in Safari, right?
I don't follow why you require the hack. Why can't you just set the original value as 0?
Regardless, you're missing the space after the 'and' in your media query. See http://www.w3.org/TR/css3-mediaqueries/#syntax example #20

Resources