-webkit-baseline-middle and -moz-middle-with-baseline - css

When using browsers web inspectors I came across two different and non-standard property for the CSS attribute vertical-align.
-webkit-baseline-middle is only available in Chrome while -moz-middle-with-baseline is available on Firefox. The naming is similar but NOT the same.
I couldn't find any information regarding these two on the web. They are not even listed on MDN.
My questions:
Are they part of any standards?
What is the expected behavior when
using them?

#VSG24:
Are they part of any standards?
Both properties are not part of any standards, according to W3C CSS reference. They only seem to be used by Webkit and Gecko to behave correctly, as expected in CSS 2.1 specification:
Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
CSS 2.1 specs, p170
#VSG24:
What is the expected behavior when using them?
After some search on the web, here's what I've found about -webkit-baseline-middle on the Safari CSS Reference:
vertical-align: -webkit-baseline-middle:
The center of the element is aligned with the baseline of the text.
I was unable to get any info about -moz-middle-with-baseline other than this one :
Q: Webkit-baseline-middle - are there alternatives?
A: the same, only for Mozilla >vertical-align: -moz-middle-with-baseline;
https://toster.ru/q/255210
Below is a test, you may try it using Webkit based browsers (such as Chrome) and Gecko (Firefox):
div {
width: 15%;
height: 100px;
display: inline-block;
box-sizing: border-box;
}
hr {
width: 100%;
position: absolute;
top: 90px;
height: 1px;
background: hotpink;
border: none;
}
.container {
border: 2px solid hotpink;
position: absolute;
top: 0;
left: 0;
height: 200px;
width: 100%;
z-index: -1;
}
.reference {
background: darkblue;
}
.standard {
background: teal;
vertical-align: middle;
}
.moz {
background: antiquewhite;
vertical-align: -moz-middle-with-baseline;
}
.webkit {
background: darksalmon;
vertical-align: -webkit-baseline-middle
}
<div class="container">
<hr />
<div class="reference"></div>
<div class="standard"></div>
<div class="moz"></div>
<div class="webkit"></div>
</div>
References :
Safari and WebKit implement a large subset of the CSS 2.1 Specification defined by the World Wide Web Consortium (W3C), along with portions of the CSS 3 Specification. This reference describes the supported properties and provides Safari availability information. If a property is not listed here, it is not implemented by Safari and WebKit.
Safari CSS Reference
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification
Hope I helped a bit :)

Related

Having a fallback for a transparent background RGBA background in CSS

I have a div over an image that I use on hover to have some kind of milky layer, which I get with background-color:rgba(255,255,255,0.1).
As I am cross browser testing my web site, I realize that rgba is not supported by IE8. So what I would like is not to have the milky layer at all when rgba is not supported. Here below what I tried as fallback:
1/ background-color:rgba(255,255,255,0.1);
2/ background-color:transparent; background-color:rgba(255,255,255,0.1);
3/ background-color:none; background-color:rgba(255,255,255,0.1);
With all three tries, I have a full blank layer over my image. How can I accomplish this?
I think the following will work.
Wrap the image in a container:
<div class="img-overlay">
<img src="http://placekitten.com/200/200">
</div>
apply the following CSS:
.img-overlay {
border: 1px solid blue;
float: left;
position: relative;
}
.img-overlay:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: white;
filter: alpha(opacity=40); /* internet explorer */
opacity: 0.4; /* fx, safari, opera, chrome */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=40)"; /*IE8*/
}
img {
display: block;
}
See demo at http://jsfiddle.net/audetwebdesign/DkRJs/
The idea is to use absolute positioning to position an element over the image and then apply the opacity property.
If the older browsers don't support the pseudo element, you will need to place in the HTML code directly.
Note: I just reread the original question and realized that I solved the wrong problem.
Sorry for the inconvenience.
IE8 Issue
I tested this in IE8 and just realized that you need the filter property to make it fully backwards compatible.
It's not ideal but you could use a 1px by 1px transparent png as a repeating background image.
You could even do this using IE conditional comments so as just to target IE8.
You could also use:
img:hover{opacity:0.8}

CSS perspective not working in Internet Explorer 10 or Firefox

I've got a jQuery image scroller that simulates depth using the perpective and transform: translateZ CSS properties. It renders correctly in Chrome, but not in IE10 or Firefox.
Here is the full project (click on the "Who's coming" menu link to see the image scroller):
http://www.girlguiding.org.uk/test/biggig/index.html
and here is a jsFiddle of the relevant code:
http://jsfiddle.net/moosefetcher/rxCMr/28/
(I'm not sure why, but stackoverflow is telling me I need to include code to link to jsFiddle, so here's the css)...
.scroller {
position: relative;
perspective: 150;
-webkit-perspective: 150;
-ms-perspective: 150;
-moz-perspective: 150;
}
.artistBox {
width: 228px;
height: 268px;
background-color: #000000;
border-radius: 16px;
position: absolute;
overflow: hidden;
z-index: 4;
}
.artistBox p {
position: absolute;
font-family:"Arial", sans-serif;
color: white;
font-size: 22px;
}
.artistBoxFront {
z-index: 5;
}
.artistBoxNew {
z-index: 3;
opacity: 0;
}
.scrollerButton {
position: absolute;
top: 128px;
width: 32px;
height: 32px;
border: 2px solid white;
border-radius: 32px;
background-color: #F49D19;
box-shadow: 1px 1px 3px #555588;
z-index: 6;
}
.scrollerButtonOver {
background-color: #ffaa26;
box-shadow: 2px 2px 3px #555588;
}
Note that I have tried this both including AND excluding the -ms- prefix on the properties. (The current jsFiddle includes both, as well as -webkit- and -moz-).
Anyone know why this might not be working in IE10?
Cheers.
Unit of length
IE and Firefox require a unit of length on perspective values (px, em).
-moz-perspective: 800px;
perspective: 800px;
For Chrome and Safari, the unit of length is optional when using the -webkit prefix.
-webkit-perspective: 800; /* This works with or without the px unit */
W3C standards
It's safer to add a unit of length to all perspective values. It's more consistent with the W3C standard. It's the one approach that all browsers support. And once Chrome and Safari start supporting perspective without a prefix, it's possible that they'll require a unit of length (for consistency with W3C standards and with other browsers).
-webkit-perspective: 800px;
-moz-perspective: 800px;
perspective: 800px;
Note: The current info on w3schools.com is outdated. There's no mention of support for IE10 or Firefox, and their examples do not have a unit of length. The more-recent examples on developer.mozilla.org include a unit of length, consistent with the W3C standards.
It isn’t working as no WebKit browser drops the perspective property. That property either accepts none or a length value. Lengths require a unit, unless the value is 0. If you add a unit, such as px, it works in IE and Firefox.
See http://jsfiddle.net/rxCMr/31/
I removed the -ms- property as perspective was added to IE10 without a prefix in the final version. I also moved the unprefixed version last, so that it wins out over the prefixed versions.
I'm not sure why it is working in WebKit. It should drop the property like Firefox and IE, but I guess it is doing error recovery.
I was using Matthew Wagerfield's ParallaxJS and perspective: 4000px but it still wasn't working in IE10/11, while being absolutely fine in Chrome and Firefox.
The markup
<ul class="container">
<li class="layer">...</li>
<li class="layer">...</li>
<li class="layer">...</li>
</ul>
Defining perspective: 4000px on the .container was fine for FF and Chrome, but it only started working for IE when being defined on the .layer. So maybe check for that. Might have something else to do with the myriad of transform-style: preserve-3d || flat that I've set, but the gist is: check on which selector your perspective is set.

Target CSS only Firefox on Mac

I have some alignment problem in my coding. In Windows, all the browsers seems okay. But when I checked it in Mac firefox, the alignment is not perfect. I can fix it by changing the value a bit. But it should be only for Firefox on Mac.
Is there any CSS attributes or something for this?
Example: http://jsfiddle.net/9chk5/
.notes {
display: inline-block;
position: relative;
width: 16px;
height: 16px;
margin: 0 auto;
background: #abc;
}
.search-notes {
font-size: 14px;
color: #484848;
position: relative;
top: -20px;
margin: 0 25px 0 22px;
}
and the HTML
<div class="notes" style="top:2px"></div><div class="search-notes">This link is used to get information about the visitors from the google organic search. This link is used to get information about the visitors from the google organic search. This link is used to get information about the visitors from the google organic search. This link is used to get information about the visitors from the google organic search. </div>
</div>
You can use classes to achieve what you want. Sniff out the user's Browser and OS and add a class to body for your specific case. E.g. apply macFirefox class to body if user is using Firefox on Mac, then in CSS use .macFirefox .yourClass { /*CSS rules*/ }.
However it will be better to apply styles in a way which are crossbrowser.
For example in your particular case changing style to
.search-notes {
font-size: 14px;
color: #484848;
position:absolute;
display:inline;
/* position: relative;
top: -20px;
margin: 0 25px 0 22px; */
}
should do the trick.
Updated your fiddle
You can step into the gray area of undocumented feature queries. This way you can target only Firefox on Mac:
#supports (-moz-osx-font-smoothing: auto) {
#firefox-on-mac { display: block; }
}
And if you want to target all Firefox, except those which are on Mac, do this:
#supports (-moz-appearance: none) and (not (-moz-osx-font-smoothing: auto)) {
#firefox-not-on-mac { display: block; }
}
I am deliberately not using #-moz-document, because it has been disabled for public use per Firefox bug #1035091.
See this codepen for practical example.

CSS: Text over Image - IE8 problem

I have images that have statistics texts printed over them. This worked well with FF, Chrome and IE9 but not on IE8. I cant just seem to figure out what is the problem here.
HTML:
<div>
<div class="image">
<img src="#Url.Content("~/stuff/stuffImage.png")" alt="" />
<GIR1><span>#ViewBag.stuffArray[4]%</span></GIR1>
</div>
</div>
CSS:
.image {
position: relative;
width: 100%; /* for IE 6 */
}
GIR1 {
position: absolute;
top: 110px;
left: 50px;
width: 100%;
}
GIR1 span{
color: white;
font: bold 15px/15px Helvetica, Sans-Serif;
letter-spacing: -1px;
padding: 10px;
}
Instead of positioning the text inside the picture. It positions them outside it like normal text. What could cause the problem here?
I'm reasonably sure it's down to your usage of the custom element <GIR1>.
IE below version 9 does not natively recognize unknown elements.
You can either switch to <div class="GIR1"> (which would be the easy choice here), or:
You have to use a JavaScript fix: http://code.google.com/p/html5shiv/
Note that you'll have to add the custom element to the script yourself.
For the uncompressed version, see: http://www.iecss.com/print-protector/
var elems = 'abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video'
You need to add your custom elements to that list.

is there any solution to get support of CSS Gradient in firefox 3.5 and lower?

is there any solution to get support of CSS Gradient in firefox 3.5 and lower?
http://hacks.mozilla.org/2009/11/building-beautiful-buttons-with-css-gradients/
I would strongly advise you to just use a BG image. I know everyone can't wait to start using all the latest whiz-bang CSS3 features, but we're all just gonna have to wait for these parts of CSS3 to be adopted by the major browsers (which will happen before CSS3 reaches a W3C Recommendation).
Using vendor-specific extensions is a bad practice IMO and seems like a throw-back to the days when nobody cared about web standards, and web developers either, just coded for a single browser (along with tacky Designed for IE buttons), or had to write the same code multiple ways to support different browsers. All the major browsers now have support for PNG alpha layer transparency. So there's really little advantage to force the use of CSS to generate gradients. It only introduces unnecessary code redundancy.
If you're still set on absolutely not using BG images, then the only option is to use JavaScript. Here is a script that should work in Firefox 3 and up, perhaps even Firefox 2: JavaScript Gradient Roundrects.
The code would look something like:
var style = {
'gradient-start-color': 0x99ddff,
'gradient-end-color': 0xffffff,
'border-radius': 1
};
OSGradient.applyGradient(style, $('#Disp')[0]);
But this is still a roundabout way to achieve a result that could be obtained with a simple 1x50px PNG image.
While this article "Cross-Browser CSS Gradient" explain how to use the css3 gradient feature in all browsers, it is still limited to FireFox 3.6+.
So this old article from 2006 List Apart "Super-Easy Blendy Backgrounds" might offer an alternative (but not for all use case you might need)
CSS3 is going to implement a background-size attribute, but since CSS3 has an ETA of never, that’s no help now. So what do we do?
Well, we use something that will scale, like the img element. Instead of using a background to display the PNG blend, we can use an img element, and set the width and the height to 100%.
, with a CSS like:
<style type="text/css">.grad img {
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
z-index: 0;
}
.box {
border: solid orange 2px;
float: left;
margin: 1px;
position: relative;
width: 165px;
padding: 5px;
}
.box * {
margin: 0px;
position: relative;
z-index: 1;
}
* html .grad {
filter: progid:DXImageTransform.Microsoft.AlphaImage »
Loader (src='grad_white.png', sizingMethod='scale');
}
* html .grad img {
display: none;
}
* html .box {
position:static;
}
.blue {
background-color: #2382a1;
}
.green {
background-color: #4be22d;
}
.pink {
background-color: #ff009d;
}
</style>
<!--[if IE 7]>
<style type="text/css">
.box {
border: solid red 2px;
height:2.5em;
}
</style>
<![endif]-->
and the markup:
<div class="box grad blue">
<img src="grad_white.png" alt="blur gradient box" />
<p>Ooo, linked text!</p>
</div>
<div class="box grad pink">
<img src="grad_white.png" alt="pink gradient box" />
<p>Ooo, linked text!</p>
</div>
<div class="box grad green">
<img src="grad_white.png" alt="green gradient box" />
<p>Ooo, linked text!</p>
</div>

Resources