【发布时间】:2014-10-15 22:30:47
【问题描述】:
我正在使用 css rotate 来旋转图像。它工作正常,但也没有调整其他元素。 它与其他元素重叠。如果我旋转图像,我想要什么,那么它不应该与其他元素重叠,而是相应地调整它的高度和宽度。 请在下面查看我的代码
HTML
<div id="wrapper">
<h1>Heading 1</h1>
<img id="testimg" src="http://thecutestblogontheblock.com/wp-content/uploads/2012/10/Owl-Walk-free-cute-halloween-fall-blog-BANNER.png" alt="" />
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<button>Rotate</button>
JQuery
var degrees = 0;
$("button").click(function(){
degrees += 90;
var img = $("#testimg");
img.css({
"-webkit-transform": "rotate(" + degrees + "deg)",
"-moz-transform": "rotate(" + degrees + "deg)",
"transform": "rotate(" + degrees + "deg)" /* For modern browsers(CSS3) */
});
});
请检查我在 JS fiddle "http://jsfiddle.net/FcQZm/" 中的代码 非常感谢您的帮助
【问题讨论】:
标签: jquery html css rotatetransform