I was making my website using mozilla and chrome and edge as the main resource to see if It was working good dynamically.
But when I opened the IE browser my css, like "transforms" where all formatted in a odd way, the places where they were originally were not the same anymore in IE.
Is there a way to make css do a selection or restrict for each browser, like for chrome It uses "transform" then on IE it would use "right".
I can't use "right" on chrome or it will be desformatted so, I would like to know if there is a special condition.
When writing CSS or JS you'll want to check browser compatibility tables for the features that you use. You can find this on official resource websites such as https://www.w3schools.com/cssref/css3_browsersupport.asp
For transforms in particular, have a look at: https://www.w3schools.com/cssref/css3_pr_transform.asp
You'll either need to use features that are compatible across all the browsers that you wish to support (taking into account their versions) or, as you mentioned, code alternatives by detecting what features are available in your user's browser. A tool such as https://modernizr.com/ can help with that.
use following hacks for browsers specification.
google chrome:
#media screen and (-webkit-min-device-pixel-ratio:0)
{
#element { properties:value; }
}
firefox:
#-moz-document url-prefix() {
#element { properties:value; }
}
Opera:
#media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
#element { properties:value; }
}
safari:
#media screen and (-webkit-min-device-pixel-ratio:0) {
#element { properties:value; }
}
Internet Explorer 9 and lower :
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
Internet Explorer 10 & 11 :
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
}
Microsoft Edge 12 :
#supports (-ms-accelerator:true) {
/* IE Edge 12+ CSS styles go here */
}
And for future details and specification see following links W3school & Site Point
Related
I am using simple method to target IE only CSS.
<!--[if !IE]><!-->
<body>
<!--<![endif]-->
<!--[if IE]>
<body class="ie">
<![endif]-->
<div class="Out">My test content
</div>
External CSS
.Out{
width:300px;/*Not for IE*/
}
ie. Out{
width:300px; /*only for IE*/
}
But In FF & chrome developer tool I am seeing body get class="ie" which is wrong.class="ie" is only for IE browsers.
There are number article I have referred
Reference:
https://css-tricks.com/snippets/html/add-body-class-just-for-ie/
https://css-tricks.com/how-to-create-an-ie-only-stylesheet/
Detecting IE11 using CSS Capability/Feature Detectionenter link description here
http://www.positioniseverything.net/articles/cc-plus.html .....etc list goes on
I have referred numbers of article but not helping.I think I am missing some things.
I have tried lots of thing from various source and article as I mentioned in my question.
Fortunately what work for me is answer from "SW4" in how-to-write-a-css-hack-for-ie-11
IE 8,9 and 10
.Out {
width:400px\0; /*For IE 8,9 and 10.*/
/* For me above code is also supporting in IE 11 also. However, for IE 10+ browser I have added media query using -ms-high-contrast below*/
width: 300px; /*for other Browsers*/
}
Here’s the technique, which is really rather simple: create a media query using -ms-high-contrast, in which you place your IE 10 and 11-specific CSS styles. Because -ms-high-contrast is Microsoft-specific (and only available in IE 10+), it will only be parsed in Internet Explorer 10 and greater.
-ms-high-contrast supports two values: none and active. So to target IE10+ regardless of the property’s setting, use this media query:
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
width:400px; /* IE10+ CSS styles go here */
}
I know that I can detect IE 10+ with the following media query:
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
}
I helps me write IE specific code if needed. The question is how do I write code for any other browser, except for IE10+? Something like if not #media ... { my code here }
PS: I know these are dirty tricks, but I am totally lost.
The simplest thing would be to declare the common styles and styles for all non-IE10+ browsers before that media query, then override them as necessary within the media query to make whatever changes IE10+ require.
If you need to target specific browsers these will get you anything Webkit and Firefox respectively:
#supports (-webkit-appearance:none) {
Styles Go Here for Safari and Chrome
}
Firefox is a bit messier:
_:-moz-tree-row(hover), .classname {
Styles Go Here
}
Repeated for each class/id/whatever
I am looking for a way to only target chrome browsers within a mixin in scss.
#mixin {
&:after {
border-bottom:black;
#media screen and (-webkit-min-device-pixel-ratio:0) { border-bottom: red; }
}
}
This targets both safari and chrome at the moment.
There is no particular hack for css alone whereas you can override the css of the safari
FOR WEBKIT
#media screen and (-webkit-min-device-pixel-ratio:0) {
.class{color:red;}
}
Safari only override
::i-block-chrome,.class {
color:blue;
}}
If you are looking for a media query, Chrome versions can be separated now. A while back I created this from research of combinations until I found a method that would work. I posted it months ago to browserhacks.com (I do testing for them). Chrome 29+ is targetable via media query. At this time, it is tested working in all modern versions of Chrome even development and Canary versions up to version 40.
Try this instead of the Chrome + Safari media query embedded in your mixin:
#media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
border-bottom: red;
}
There are live tests I have posted as well for this and others that I have worked on or created here:
http://browserstrangeness.bitbucket.org/css_hacks.html
Try this:
#supports (-webkit-appearance:none) {}
The CSS within the curly brackets will only run if your browser supports webkit (Chrome).
Browserhacks is a great resource for 'browser specific CSS and JavaScript hacks'
Here is my code for IE9 and above:
<!--[if gte IE 9]>
<style type="text/css">
#bottom p{
font-size:10pt!important;
}
#pop_cities{
font-size:14pt !important;
font-weight:bold !important;
padding-right:10px !important;
}
</style>
<![endif]-->
How can I apply these style for the version 9 of Internet Explorer and above?
Conditional comments are no longer supported:
http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx
They don't work for version 10 and greater.
There is a hack for Internet Explorer 10, which you might want to use:
. ie10 #hack{
/* Only works in IE10 */
}
Maybe you have to arm yourself with some JavaScript for the fight against the future versions of Internet Explorer, if you can't fix the underlying problem. For example with JQuery:
if ($.browser.msie && $.browser.version == 10) {
$("html").addClass("ie10");
}
As #Spudley mentioned, the $_browser property is deprecated and already removed in the newer version of jQuery. Maybe it's better to check the browser for e certains feature you need. For example with Modernizr. This is also recommended in the JQuery documentation.
Conditional comments supported IE9 and below version
IE 10+ browser support #media screen
#media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/*css*/
}
See this fiddle http://jsfiddle.net/GEQxj/1/
I have tried several suggestions like
float:none;
overflow:visible;
display:block;
break-before: always;
What i want to accomplish - is the table with the child class to be to be printed in a landscape fashion. The rotation works across all browsers. However the page-break-before only works in ie8 at the moment. Does not work in latest versions of FF Chrome and Safari.
This page is generated from another page for the sole purpose of being printed so no need for #media print.
Try adding this:
margin-top:280px;
margin-left:-230px;
It looks good in chrome and firefox http://jsfiddle.net/GEQxj/23/
You can target just webkit browsers and firefox with this:
#media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari and Chrome CSS here */
}
#-moz-document url-prefix() {
/* Firefox CSS here */
}