VanillaJS创建的自定义添加/删除带有卡片布局

所属分类: 网页特效-其它&杂项    2024-03-27 09:38:14

VanillaJS创建的自定义添加/删除带有卡片布局 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

VanillaJS创建的自定义添加/删除带有卡片布局(共3个文件)

    • index.html

使用方法

document.querySelector('.cards').addEventListener('click', e => {
	if (e.target.classList.contains('delete-btn')) {

		if (!document.startViewTransition) {
			e.target.parentElement.remove();
			return;
		}

		e.target.parentElement.style.viewTransitionName = 'targeted-card';
		document.startViewTransition(() => {
			e.target.parentElement.remove();
		});
	}
})

document.querySelector('.add-btn').addEventListener('click', async (e) => {
	const template = document.getElementById('card');

	const $newCard = template.content.cloneNode(true);

	if (!document.startViewTransition) {
		document.querySelector('.cards').appendChild($newCard);
		return;
	}

	$newCard.firstElementChild.style.viewTransitionName = 'targeted-card';
	$newCard.firstElementChild.style.backgroundColor = `#${ Math.floor(Math.random()*16777215).toString(16)}`;
	const transition = document.startViewTransition(() => {
		document.querySelector('.cards').appendChild($newCard);
	});

	await transition.finished;

	const rand = window.performance.now().toString().replace('.', '_') + Math.floor(Math.random() * 1000);
	document.querySelector('.cards .card:last-child').style.viewTransitionName = `card-${rand}`;

});

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它&杂项

Bootstrap创建的流程步骤向导布局界面

这是一款步骤向导CSS布局代码,引导用户如何按步骤去操作,每个步骤都有明确的说明和提示,还带有图标和描述进行说明。
  其它&杂项
 153  

jquery不良文字过滤审查替换插件代码

一款简单高效的文字替换插件,可将指定文字替换成自定义字符,非常实用!
  其它&杂项
 172  

纯CSS创建的透明变色的button按钮效果

一款很奇妙的透明按钮特效,滚动页面当按钮悬停于背景图片上时,自动变更button背景透明色,根据不同的背景图片进行不同的变换。
  其它&杂项
 57  

jquery可获取文本框最初光标停留位置插件

一款表单文本框光标获取位置插件,可获取当前光标停留位置字符串总数,以及回到最初光标停留位置。
  其它&杂项
 75  

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论