我想点击document
让p
的图片从中心点向两边展开一张图片的大小
用了css3
的缩放,但是他会把图片弄失真,问下用css3
能否实现
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
p {
width:1px;
background:url(http://www.ppt123.net/beijing/UploadFiles_8374/201203/2012032518062306.jpg);
background-size:cover;
height:600px;
margin:100px auto;
-webkit-transform-origin:left top;
-moz-transform-origin:left top;
-o-transform-origin:left top;
-ms-transform-origin:left top;
transform-origin:left top;
-webkit-transition:1s;
-moz-transition:1s;
-o-transition:1s;
}
</style>
</head>
<body>
<p class="outter"></p>
<script src="http://cdn.bootcss.com/jquery/2.2.1/jquery.js"></script>
<script>
$(function() {
$(document).on('click',function(){
$('p').css({
'-webkit-transform':'scaleX(800)',
'transform':'scaleX(800)'
})
})
});
</script>
</body>
</html>
Method 1: js
Method 2: scale
Method 3: Pure CSS
Your picture is a bitmap, and it will definitely be distorted when enlarged. You need to use a vector image. You can also achieve this with css3, but you need to use a higher version of the browser. But the picture will still be distorted.
You will definitely get distortion if you only zoom in by x. . If it’s blurry, you need to use vector