Transform scale on :first-letter in Firefox and IE

自古美人都是妖i 提交于 2019-12-10 17:49:48

问题


I am making drop-caps for the first letter of a paragraph using transform: scale on the pseudo element :first-letter. It works great in Chrome but not in Firefox, although transform: scale and :first-letter both work in Firefox for themselves.

HTML

<p>Lorem ipsum dolar sit amet</p>  

CSS

p:first-letter {
float: left;
margin-left: -36px;
margin-top: 10px;
font-size: 53px;
transform: scale(1,2);
-ms-transform: scale(1,2);
-webkit-transform: scale(1,2);
-moz-transform: scale(1,2);
}

Here is a jsfiddle


回答1:


Apparently, attempting to transform the :first-line and :first-letter pseudo-elements was crashing Firefox, so it was disabled. That was a long time ago, however; it may be worth revisiting in a new bug report.

There does not appear to be a pure CSS workaround, but you might be able to get away with using JavaScript to transplant the first letter into a child element and transforming that child element, instead of using :first-letter:

var p = document.querySelector('p');
var text = p.innerHTML;
p.innerHTML = '<span>' + text.charAt(0) + '</span>' + text.substring(1);

Updated fiddle



来源:https://stackoverflow.com/questions/24435595/transform-scale-on-first-letter-in-firefox-and-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!