您的位置:首页技术文章
文章详情页

javascript - 对元素scale缩放时,滚动只能看到放大后右下方的内容.

浏览:72日期:2023-06-19 16:19:07

问题描述

<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'></head><body><p style='width: 970px;height: 651px;overflow: auto'> <img src='https://cloud.githubusercontent.com/assets/6072743/26030200/1ca3370a-387e-11e7-9c6d-8d1b029c90cc.png'></p></body></html>

左上角的缩放后的内容就看不到了。除了transfrom-origin设置为left top,请问还有什么办法吗。

问题解答

回答1:

transform-origin: 0 0;回答2:

要能滚动不能用 transform

<!DOCTYPE html><html><head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width'> <title>JS Bin</title></head><body><p style='width: 970px;height: 651px;overflow: auto'> <img onload='var parent=this.parentElement;parent.scrollTop=(parent.scrollHeight-parent.clientHeight)/2;parent.scrollLeft=(parent.scrollWidth-parent.clientWidth)/2;' src='https://cloud.githubusercontent.com/assets/6072743/26030200/1ca3370a-387e-11e7-9c6d-8d1b029c90cc.png'></p></body></html>

标签: JavaScript