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. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 列表&布局

jquery图文切换时间轴支持循环播放

一款图文切换的水平时间轴插件,通过切换图文幻灯片来转换时间线的年份,时间轴跟随图文切换而移动。
  列表&布局
 5597  0

CSS医生人员图文列表布局代码

一款卡片式横向列表布局代码,鼠标悬停背景颜色变换特效。
  列表&布局
 2709  0

jquery响应式网格布局等高特效代码

heightLine.js是一个轻量级DIV列表等高插件,在不同的分辨率下都能使网格列表达到相同的高度,并且实时输出当前显示宽度。
  列表&布局
 2714  0

css响应式图文排版布局模板代码

一款图文布局特效代码,实现了图片固定左侧或右侧,改变显示分辨率位置都不改变,大家可以查看演示试一试。
  列表&布局
 1952  0

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

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