I have a class:
.banner {
padding: 2% 33% 2% 20%;
}
In Chrome always normal, but for IE 10+ normal style: 2% 22% 2% 23%. How to define padding
style for normal working in all these browsers?
I have a class:
.banner {
padding: 2% 33% 2% 20%;
}
In Chrome always normal, but for IE 10+ normal style: 2% 22% 2% 23%. How to define padding
style for normal working in all these browsers?
/* Chrome 28+ (also affects Safari and MS Edge now) */
@supports (-webkit-appearance:none) { /* Needed styles */ }
/* Firefox (any) */
_:-moz-tree-row(hover), .selector { /* Needed styles */ }
/* Internet Explorer 11+ */
_:-ms-fullscreen, :root .selector { /* Needed styles */ }
/* Internet Explorer 10+ */
_:-ms-lang(x), .selector { /* Needed styles */ }
/* Also Internet Explorer 10+ */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/* Needed styles */
}
/* Internet Explorer 9+ */
_::selection, .selector { /* Needed styles */ }
/* Safari 6.1+, Chrome for iOS */
@media screen and (min-color-index: 0) and(-webkit-min-device-pixel-ratio: 0) { @media {
/* Needed styles */
}}
For IE9- you can apply conditional comments and add style
or link
tag there. Also they allow to add conditional markup for browsers.
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
you should avoid fixing your CSS for specific browsers, but if you really want to experiment it there are multiple solutions. you can find a lot of useful code here http://browserhacks.com/
fixing your CSS for specific browsers:
Selector hacks
/* IE6 and below */
* html #one { color: red }
/* IE7 */
*:first-child+html #two { color: red }
/* IE7, FF, Safari, Opera */
html>body #three { color: red }
/* IE8, FF, Safari, Opera (Everything but IE 6,7) */
html>/**/body #four { color: red }
/* Opera 9.27 and below, Safari 2 */
html:first-child #five { color: red }
Attribute hacks
.class {
width:200px; /* All browsers */
*width:250px; /* IE */
_width:300px; /* IE6 */
.width:200px; /* IE7 */
}
/* IE6 */
#twentyseven { _color: blue }
/* IE6, IE7 */
#twentyeight { *color: blue; /* or #color: blue */ }
/* Everything but IE6 */
#twentynine { color/**/: blue }
/* IE6, IE7, IE8 */
#thirty { color: blue\9; }
/* IE7, IE8 */
#thirtyone { color/*\**/: blue\9; }
Conditional comments
<!--[if IE]>
According to the conditional comment this is IE<br />
<link href="ie.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
I resolved my task using bellow styles in strong order:
/* IE 9+ */
_::selection, .baner{
padding: 2% 33% 2% 20%;
}
/* Chrome */
.baner{
-webkit-padding-after: 2%;
-webkit-padding-before: 22%;
-webkit-padding-start: 2%;
-webkit-padding-end: 23%;
}