javascript - 如何通过动画增加框的宽度?

标签 javascript jquery html css

我想为宽度从 20px 到 80px 的框设置动画,但仅限于框的右侧。所以这意味着当我将鼠标悬停在右侧时,右侧会增加 60px 的宽度并带有动画。它的 jquery 代码是什么?

最佳答案

仅使用 CSS3 和 HTML。无需使用 jquery。

.box {
        transition: 0.2s;
        width: 20px;
        height: 100px;
        background-color:#0066CC;
        position : absolute;
        left: 50px;
        top: 50px;
    }
    
    .box:hover {
        width: 80px;
        height: 100px;
        left: 50px;
        top: 50px;
    }
<div class="box"></div>

关于javascript - 如何通过动画增加框的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27086863/

相关文章:

javascript - 如何在 redux Action 中从 axios 调用中获取数据? React JS 搜索项目

javascript - 带有 OMS 的 Google map - 响应点击事件的标记属性

javascript - 围绕世界轴旋转对象

javascript - 将空格插入跨度内的文本失败

javascript - 使用 jQuery 提交后清除表单

javascript - 如何在 d3.js 中正确放置文本标签?

javascript - 在 Google Maps V3 中获取 GeoJSON 数据层的属性

javascript - 如何比较两个 HTML 元素的渲染

html - 带搜索栏的 Bootstrap 可折叠导航栏 : form-inline does not scale well with resizing

javascript - 如果之前未选择元素,则执行功能