Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 被切割的比例元素_Html_Css - Fatal编程技术网

Html 被切割的比例元素

Html 被切割的比例元素,html,css,Html,Css,将css比例添加到img元素,并将其引至被剪切元素的左顶部 css变换原点:0;可以解决这个问题,但这不是我想要的效果 <html> <head>scale element being cut</head> <style> .image-container { position: fixed; top: 50px; left: 50px;

将css比例添加到img元素,并将其引至被剪切元素的左顶部

css变换原点:0;可以解决这个问题,但这不是我想要的效果

<html>
    <head>scale element being cut</head>
    <style>
        .image-container {
            position: fixed;
            top: 50px;
            left: 50px;
            width: 100px;
            height: 100px;
            overflow: auto;
        }
        img {
            width: 100%;
            height: 100%;
        }
    </style>
    <body>
        <div class="image-container">
            <img id="image" src="https://avatars1.githubusercontent.com/u/9919?s=200&v=4" alt="">
        </div>
        <input type="button" onClick="scale()" value="scale image">
        <script>
            function scale () {
                document.getElementById('image').style.transform = 'scale(2)';
            }
        </script>
    </body>
</html>

被切割的比例元素
.图像容器{
位置:固定;
顶部:50px;
左:50px;
宽度:100px;
高度:100px;
溢出:自动;
}
img{
宽度:100%;
身高:100%;
}
功能量表(){
document.getElementById('image').style.transform='scale(2)';
}

我希望图像可以从中心变换,用户可以滚动查看缩放图像

scale
将仅对图像进行视觉缩放。等同于。您可以将宽度和高度改为200%:
style.height='200%'/
style.width='200%'
缩放
将仅在视觉上缩放图像。等同于。您可以将宽度和高度改为200%:
style.height='200%'/
style.width='200%'