css过渡动画,鼠标移上去就变大(缓慢变大、过渡效果、放大的过程是过渡动画的,这个过渡动画是有时间控制的)

本文介绍了如何使用CSS的transition属性创建鼠标悬停时元素缓慢放大的过渡效果。通过调整overflow、transform和cursor属性,实现平滑动画及交互体验。
摘要由CSDN通过智能技术生成
<template>
  <div>
    <div class="li">
      <img src="../assets/123.jpg" alt>
    </div>
  </div>
</template>

<script>
export default {
  props: {},
  data() {
    return {};
  },
  methods: {},
  components: {},
  mounted() {}
};
</script>

<style  lang="scss">
.li {
  width: 300px;
  height: 300px;
  border: #000 solid 1px;//设置div的边框
  margin: 50px auto;
  overflow: hidden;//overflow 属性规定当内容溢出元素框时发生的事情。http://www.w3school.com.cn/cssref/pr_pos_overflow.asp
}
.li img {
  cursor: pointer;//cursor 属性规定要显示的光标的类型(形状)
  transition: all 0.6s;//设置图片变大的属性,表示所有的属性变化在0.6s的时间段内完成。https://www.cnblogs.com/afighter/p/5731293.html
}
.li img:hover {
  transform: scale(4,4);//表示在鼠标放到图片上的时候图片按比例放大4.4倍。https://www.cnblogs.com/xiaoxingyiyi/articles/4838648.html
}
</style>
注:over
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,那么以下是实现你所需功能的代码。 HTML代码: ```html <div class="notes-container"> <div class="note"> <h3 class="note-title"></h3> <div class="note-content"></div> </div> <!-- 其他11个便签 --> </div> ``` CSS代码: ```css /* 便签容器样式 */ .notes-container { display: flex; flex-wrap: wrap; justify-content: space-between; max-width: 800px; margin: 0 auto; } /* 便签样式 */ .note { position: relative; width: calc(33.3% - 10px); height: 200px; margin-bottom: 20px; background-color: #fff; border: 1px solid #ccc; box-shadow: 0px 0px 5px #ccc; transition: transform 0.3s ease-out; } /* 鼠标上去放大过渡效果 */ .note:hover { transform: scale(1.1); } /* 便签标题样式 */ .note-title { position: absolute; top: 10px; left: 10px; font-size: 20px; } /* 便签内容样式 */ .note-content { position: absolute; top: 50px; left: 10px; font-size: 16px; } /* 通过nth-child选择器实现对便签的背景色和字体颜色控制 */ .note:nth-child(2n) { background-color: #f5f5f5; } .note:nth-child(3n) { background-color: #f0f0f0; } .note:nth-child(4n) { background-color: #e5e5e5; } /* 便签旋转效果 */ .note:nth-child(odd) { transform: rotate(-3deg); } .note:nth-child(even) { transform: rotate(3deg); } ``` JavaScript代码: ```javascript // 获取便签容器 const notesContainer = document.querySelector('.notes-container'); // 从本地存储中读取数据,假设数据格式为JSON数组 const notesData = JSON.parse(localStorage.getItem('notes')); // 遍历数据,创建便签并添加到容器中 notesData.forEach(note => { const noteEl = document.createElement('div'); noteEl.classList.add('note'); const titleEl = document.createElement('h3'); titleEl.classList.add('note-title'); titleEl.textContent = note.title; const contentEl = document.createElement('div'); contentEl.classList.add('note-content'); contentEl.textContent = note.content; noteEl.appendChild(titleEl); noteEl.appendChild(contentEl); notesContainer.appendChild(noteEl); }); ``` 这份代码实现了你所需要的功能,包括: 1. 从本地存储中读取数据,并根据数据动态生成便签。 2. 通过nth-child选择器实现对便签的背景色和字体颜色控制。 3. 便签具有旋转效果和阴影效果鼠标上去时具有放大过渡效果。 如果你有任何问题或者需要进一步的帮助,请告诉我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值