扑克牌叠加效果css_使CSS剪辑生效:扩大叠加效果

本文展示了如何使用CSS的clip属性创建一个平滑过渡效果,当点击盒子元素时显示全屏覆盖层。点击将创建剪切效果,动画展开覆盖层,而关闭按钮则会恢复原状。通过实例,详细介绍了HTML、CSS和JavaScript的实现过程。
摘要由CSDN通过智能技术生成
扑克牌叠加效果css

扑克牌叠加效果css

Putting CSS Clip to Work: Expanding Overlay Effect

Our previous article, Understanding the CSS Clip Property by Hugo Giraudel offers a great overview of the CSS clip property and the rect() function. Today we want to explore the practical side of it a little bit more. We are going to create a neat and simple effect for revealing some extra content and expanding a fullscreen overlay.

Hugo Giraudel撰写的上一篇文章“理解CSS剪辑属性”对CSS剪辑属性和rect()函数进行了很好的概述。 今天,我们想进一步探讨它的实际方面。 我们将创建一种简洁明了的效果,以显示一些额外的内容并扩展全屏覆盖。

We want to show how to leverage the CSS clip property to make a smooth transition when clicking on a box element. The idea is to show some kind of overlay as if it’s actually underneath the respective element. Clicking an element will create a cut-out effect, revealing another layer that will expand.

我们想展示在单击box元素时如何利用CSS clip属性进行平滑过渡。 这个想法是要显示某种叠加层,就像它实际上位于相应元素的下面一样。 单击一个元素将创建一个剪切效果,显示另一个将扩展的图层。

This is how we’ll do it: we will first create a list of items that will look like metro-style boxes:

这是我们的操作方式:我们将首先创建一个看起来像地铁样式的盒子的物品清单:

expandingoverlay1

Each one of the boxes will contain an element (overlay) that will be of position fixed. This element will actually spread over all the page but we won’t see it because the opacity will be set to 0. When we click on a box, we’ll use clip: rect() to crop the respective part of the inner fixed element. Then we will animate the clip to reveal all the width and height of the overlay which is our entire viewport:

每个框都将包含一个位置固定的元素(覆盖)。 该元素实际上将散布在所有页面上,但因为不透明度将被设置为0,所以我们看不到它。当单击一个框时,将使用clip: rect()裁剪内部固定的各个部分元件。 然后,我们将对剪辑进行动画处理,以显示覆盖层的所有宽度和高度,即整个视口:

ExpandingOverlay2

Clicking on the close button will reverse the effect and the overlay will minimize to the list item’s size and disappear.

单击关闭按钮将使效果相反,并且覆盖层将最小化到列表项的大小并消失。

So, let’s get started with the HTML.

因此,让我们开始使用HTML。

标记 (The Markup)

We’ll use an unordered list for the boxes. Each list item will have an icon class and an optional “span” class that will control the width of the box. Inside we’ll add some text and the overlay division. The overlay will contain a structure that will have a column layout. Since we chose a dummy weather app as our theme, we will be showing a weather forecast for the next seven days. Each of the “day” columns will have some spans which we’ll use for the weekdays, the weather icon and the temperature:

我们将为箱子使用无序列表。 每个列表项都有一个图标类和一个可选的“ span”类,它们将控制框的宽度。 在内部,我们将添加一些文本和叠加分区。 叠加层将包含具有列布局的结构。 由于我们选择了虚拟天气应用程序作为主题,因此我们将显示未来7天的天气预报。 每个“天”列都会有一些跨度,我们将它们用于工作日,天气图标和温度:


<ul id="rb-grid" class="rb-grid clearfix">

	<li class="icon-clima-1 rb-span-2">

		<h3>Lisbon</h3>
		<span class="rb-temp">21°C</span>

		<div class="rb-overlay">
			<span class="rb-close">close</span>
			<div class="rb-week">
				<div&g
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值