gpt4 book ai didi

javascript - 在 div 中滚动和缩放

转载 作者:太空宇宙 更新时间:2023-11-04 15:30:36 30 4
gpt4 key购买 nike

我有一个特殊的问题需要帮助。

我有一个 div,其中包含许多我希望能够放大的其他 div。例如,一些子 div 有文本,我希望用户能够放大以查看他们说的内容。

这是一个例子 --> http://jsfiddle.net/du5ye/3/

虽然我可能可以使用 jquery 来更改内部所有内容的类,但我不想对新大小进行硬编码,而是主包装器 div 中的每个属性都会随着用户滚动他的鼠标滚轮。此外,我希望用户能够通过拖动在 div 周围滚动,就像谷歌地图一样。这种事情可能吗?我该怎么做呢?

这是为那些宁愿避免 jsfiddle 的人准备的完整代码;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<style>
.layoutGreys {
background-color: #DDD;
border: solid thin #BBB;

padding-left: 10px;
padding-right: 10px;;

float: left;
}

.Group{
background-color: #955;
width: 50px;
height: 35px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin-bottom: 10px;
float: left;
}
.Divider{
width: 10px;
height: 35px;
float: left;
<!--border-top: medium solid #999;-->
margin-top: 10px;
}

.wrapper{
width: 560px;
height: 175px;
background-color: #333;
border: thick #888 solid;
}

</style>
<body onload="CreateBox()">
<div id="wrapper" class="wrapper">
<div class="layoutGreys">
<div class="Group"></div>
<!-- Parent -->
<div class="layoutGreys">
<!-- Parent Icon -->
<div class="Group" style="float: none;"></div>
<!-- Children -->
<div class="layoutGreys">
<div class="Group"></div>
<div class="Divider"></div>
<div class="Group"></div>
<div class="Divider"></div>
<!-- Parent -->
<div class="layoutGreys">
<!-- Parent Icon -->
<div class="Group" style="float: none; "></div>
<!-- Children -->
<div class="layoutGreys">
<div class="Group"></div>
<div class="Divider"></div>
<div class="Group"></div>
<div class="Divider"></div>
<div class="Group"></div>
</div>
</div>
<div class="Divider"></div>
<div class="Group"></div>
</div>
</div>
<div class="Group"></div>
</div>
</div>
</body>
</html>

最佳答案

你试过css zoom了吗属性(property)?或者像 scale() 这样的 css 转换?

您可以使外部 div overflow: scroll; 并绑定(bind)鼠标按下事件以滚动 div 以实现平移和拖动效果。

* I know this question is old, but It may help future visitors.

关于javascript - 在 div 中滚动和缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14480827/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com