公告
财富商城
积分规则
提问
发文
2019-07-19 07:52发布
beautiful°
I'm trying to rotate a block of text slightly like below:
Can this be done with css or do I need to use javascript?
You can do it in a cross browser fashion using CSS3's transform, and a filter for IE.
transform
filter
See: http://jsfiddle.net/dRQaw/
This is the magical tool used to generate the cross-browser CSS.
<div id="skewed">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu metus nisi. Integer non adipiscing massa. Etiam et diam magna. Mauris sit amet arcu dui, a malesuada erat.</div> #skewed { font: 21px Impact, sans-serif; text-align: center; background: #ccc } #skewed { width: 350px; height: 140px; -moz-transform: skew(-5deg, -5deg); -o-transform: skew(-5deg, -5deg); -webkit-transform: skew(-5deg, -5deg); transform: skew(-5deg, -5deg); }
It'd be CSS-only. You can use JS to manipulate the CSS, but JS itself has nothing to do whatsoever with presentation, other than being one method of changing the presentation rules.
You could use CSS. Here is CSS that will work in Firefox, Opera and Safari/Chrome.
#textToRotate { -webkit-transform: rotate(-10deg); -moz-transform: rotate(-10deg); -o-transform: rotate(-10deg); }
You can do it with CSS3 transforms:
p { -moz-transform: rotate(-15deg); -o-transform: rotate(-15deg); -ms-transform: rotate(-15deg); -webkit-transform: rotate(-15deg); transform: rotate(-15deg); }
最多设置5个标签!
You can do it in a cross browser fashion using CSS3's
transform
, and afilter
for IE.See: http://jsfiddle.net/dRQaw/
This is the magical tool used to generate the cross-browser CSS.
It'd be CSS-only. You can use JS to manipulate the CSS, but JS itself has nothing to do whatsoever with presentation, other than being one method of changing the presentation rules.
You could use CSS. Here is CSS that will work in Firefox, Opera and Safari/Chrome.
You can do it with CSS3 transforms: