从中心放大

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div1{
            width:100px;
            height: 100px;
            background: #ccc;
            position: absolute;
            left:200px;
            top:200px;
        }
        #div2{
            width: 200px;
            height:200px;
            background: yellow;
            position: absolute;
            left:200px;
            top:200px;
            margin-left: -50px;
            margin-top:-50px;
        }

    </style>
    <script src="move3.js"></script>
    <script>

    </script>
</head>
<body>
<div id="div2"></div>
<div id="div1"></div>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 C# 中实现窗体载入时从中心放大的动画效果,可以使用 `System.Windows.Forms.Timer` 控件和 `Graphics` 类的缩放方法。以下是实现该效果的代码示例: ```csharp public partial class Form1 : Form { private float scale = 1.0f; private Timer timer; public Form1() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; // 设置窗体在屏幕中央 this.timer = new Timer(); this.timer.Interval = 10; this.timer.Tick += new EventHandler(timer_Tick); this.timer.Start(); } private void timer_Tick(object sender, EventArgs e) { if (scale < 1.0f) { scale += 0.1f; // 每次缩放 0.1 倍 this.Invalidate(); // 重绘窗体 } else { this.timer.Stop(); // 动画结束,停止计时器 } } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.ScaleTransform(scale, scale); // 缩放窗体 } } ``` 在上面的代码中,我们定义了一个名为 `scale` 的变量,用于保存窗体的缩放比例;另外,我们创建了一个 `System.Windows.Forms.Timer` 控件,用于定时执行动画效果。在 `Form1` 的构造函数中,我们将计时器的 `Interval` 属性设置为 10 毫秒,每次执行 `timer_Tick` 方法时,窗体的缩放比例 `scale` 将增加 0.1 倍,直到达到 1.0 倍为止。我们在 `OnPaint` 方法中使用 `Graphics` 类的 `ScaleTransform` 方法进行窗体的缩放操作。最后,在 `Form1` 的构造函数中启动计时器,以开始动画效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值