javascript - 使用 CSS 变换使 div 变大,但似乎无法让其他 div 移动
问题描述
所以我有一些代码在鼠标悬停时使 div 变大,
$('.resumeBox').mouseenter(function(){
$(this).css("transform","scale(2)");
});
$('.resumeBox').mouseleave(function(){
$(this).css("transform","scale(1)");
});
我遇到的问题是我似乎无法让其他 div 移开它的方式。我已经尝试了我能想到的每个位置或显示,但它们只是不断重叠。
如果我解释得不好,这里是孤立的。 https://codepen.io/seanmc10/pen/XOwLbJ
解决方案
没用transform: scale()
没用witdh and height
HTML
<button onclick=doThing()>Click to do thing</button>
<div id="box"></div>
<div id="box2">I want this to move down not get covered up </div>
CSS
#box{
background-color: red;
width: 100px;
height: 100px;
transform: scale(1);
transform-origin: top left;
transition: 500ms ease-in;
}
#box2{
float: left;
background-color: yellow;
width: 100px;
height: 100px;
}
JS
var c = 0;
var initialValue = 100;
function doThing(){
if (c==1){
//the if statement is just resetting the box if already big
$('#box').css({
height: (initialValue + (initialValue / 2 )) + 'px',
width: (initialValue + (initialValue / 2 )) + 'px'
});
c = 0;
} else {
$('#box').css({
height: initialValue+'px',
width: initialValue+'px',
});
c=1;
}
}
推荐阅读
- angular - ngx-extended-pdf-viewer 访问 PDF 时出现 CORS 问题
- django - Django - 基于href的过滤器?
- python - 如何将一列数组添加到形状为 10000*17 的现有数组中
- c# - HTTP 范围请求不适用于 IIS Express 静态资源
- java - 如何构建共享相同基础/公共库的项目?
- arrays - 如何从 vb.net 中的不同按钮访问表单数组?
- python - Python请求库POST请求不起作用
- javascript - 删除未使用的 Javascript base.js (Youtube iframe api)
- flutter - 测试 Flutter Facebook Firebase 登录
- javascript - 如何从嵌套字典中的值创建 [number, number][ ] 类型的列表?