当前位置: 首页 > 编程日记 > 正文

愉快的舞会c++_如何在5分钟内建立一个令人愉快的加载屏幕

愉快的舞会c++

First, here is what we will build. Set your timer!

首先,这是我们将要建立的。 设置您的计时器!

Does this look familiar?

这看起来很熟悉吗?

If yes, that’s because you’ve seen this somewhere — Slack!

如果是,那是因为您在某个地方看到了此内容- 松弛 !

Let’s learn a few things by recreating this with just CSS and some good ol’ HTML.

让我们通过仅使用CSS和一些不错HTML来重新创建它来学习一些东西。

If you’re excited about writing some code, get on Codepen and create a new pen.

如果您对编写一些代码感到兴奋,请使用Codepen并创建一支新笔。

Now, let’s go!

现在,走吧!

1.标记 (1. The Markup)

The markup required for this is quite simple. Here it is:

为此所需的标记非常简单。 这里是:

<section class="loading">
For new sidebar colors, click your workspace name, then     Preferences > Sidebar > Theme
<span class="loading__author"> - Your friends at Slack</span>;    <span class="loading__anim"></span>
</section>

Simple, huh?

简单吧?

If you’re not sure why the class names have weird dashes, I explained the reason behind that in this article.

如果您不确定类名为何带有奇怪的破折号,我将在本文中解释其背后的原因。

There’s a bunch of text, and a .loading__anim span to “impersonate” the animated icon.

有一堆文本,并且有一个.loading__anim范围来“模拟”动画图标。

The result of this is the simple view below.

其结果是下面的简单视图。

2.将内容居中 (2. Center the Content)

The result isn’t the prettiest of stuff to behold. Let’s have the entire .loadingsection element entered in the page.

结果并不是最漂亮的东西。 让我们在页面中输入整个.loading部分元素。

body {  display: flex;  justify-content: center;  align-items: center;  min-height: 100vh;}

Looking better?

看起来好点吗?

3.设置加载文本的样式 (3. Style the Loading text)

I know. We will get to the animated stuff soon. For now, let’s style the .loading text to look a lot better.

我知道。 我们将尽快处理动画。 现在,让我们设置.loading文本的样式, .loading看起来更好。

.loading {  max-width: 50%;  line-height: 1.4;  font-size: 1.2rem;  font-weight: bold;  text-align: center;}

4.设置作者文本的样式以使其略有不同。 (4. Style the author text to look slightly different.)

.loading__author {  font-weight: normal;  font-size: 0.9rem;  color: rgba(189,189,189 ,1);  margin: 0.6rem 0 2rem 0;  display: block;}

There you go!

你去!

5.创建动画加载器 (5. Create the animated loader)

The much-anticipated step is here. This is going to be the longest of the steps, because I’ll be spending some time to make sure you understand how it works.

备受期待的步骤就在这里。 这将是最长的步骤,因为我将花一些时间来确保您了解其工作原理。

If you get stuck, drop a comment and I’ll be happy to help.

如果您遇到困难,请发表评论,我们将竭诚为您服务。

Hey, have a look at the loader again.

嘿,再看看装载机。

You’ll notice that half of its stroke is blue and the other half is grey. Okay, that’s sorted out. Also, HTML elements aren’t rounded by default. Everything is a box element. The first real challenge will be how to give the .loading__anim element half borders.

您会注意到其笔触的一半是蓝色,另一半是灰色。 好的,已经解决了。 另外, HTML元素默认情况下也不四舍五入。 一切都是盒子元素。 第一个真正的挑战是如何为.loading__anim元素设置半边框。

Don’t worry if you don’t understand this yet. I’ll come back to it.

如果您还不了解这一点,请不要担心。 我会回到它。

First, let’s sort out the dimensions of the loader.

首先,让我们整理一下装载机的尺寸。

.loading__anim {  width: 35px;  height: 35px; }

Right now, the loader is on the same line as the text. That’s because it is a span element which happens to be an HTML inline element.

现在,加载程序与文本在同一行。 那是因为它是一个span元素,恰好是HTML inline元素。

Let’s make sure the loader seats on another line, that is it begins on another line as opposed to the default behavior of inline elements.

让我们确保加载器位于另一行,即它是从另一行开始的,而不是inline元素的默认行为。

.loading__anim {   width: 35px;   height: 35px;   display: inline-block;  }

Finally, let’s make sure the loader has some border set.

最后,让我们确保加载程序设置了一些边框。

.loading__anim {   width: 35px;   height: 35px;   display: inline-block;   border: 5px solid rgba(189,189,189 ,0.25);  }

This will give a greyish 5px border around the element.

这将在元素周围显示一个灰色的 5px边框。

Now, here’s the result of that.

现在,这就是结果。

Not so great — yet. Let’s make this even better.

不太好-尚未。 让我们做得更好。

An element has four sides, top, bottom,left, and right

一个元素有四个边,即topbottomleftright

The border declaration we set earlier was applied to all the sides of the element.

我们之前设置的border声明应用于元素的所有侧面。

To create the loader, we need two sides of the element to have different colors.

要创建加载程序,我们需要元素的两侧具有不同的颜色。

It doesn’t matter what sides you choose. I have used the top and left sides below

选择哪一方都没有关系。 我已经使用了下面的topleft

.loading__anim {  width: 35px;  height: 35px;  display: inline-block;  border: 5px solid rgba(189,189,189 ,0.25);  border-left-color: rgba(3,155,229 ,1);  border-top-color: rgba(3,155,229 ,1);  }

Now, the left and top sides will have a blueish color for their borders. Here’s the result of that:

现在, lefttop的边框将变为蓝色 。 结果如下:

We’re getting somewhere!

我们到了某个地方!

The loader is round, NOT rectangular. Let’s change this by giving the .loader__anim element a border-radius of 50%

装载机是圆形的,不是矩形的。 让我们通过为.loader__anim元素设置50%border-radius来更改此设置

Now we have this:

现在我们有了这个:

Not so bad, huh?

还不错吧?

The final step is to animate this.

最后一步是对此进行动画处理。

@keyframes rotate { to {  transform: rotate(1turn) }}

Hopefully, you have an idea of how CSS animations work. 1turn is equal to 360deg , that is a complete turn rotates 360 degrees.

希望您对CSS动画的工作原理有所了解。 1turn等于360deg ,这是一个整圈旋转360度。

And apply it like this:

并像这样应用它:

animation: rotate 600ms infinite linear;

Yo! We did it. Does that all make sense?

! 我们做到了。 这一切有意义吗?

By the way, see the result below:

顺便说一下,请看下面的结果:

Pretty cool, huh?

太酷了吧?

If any of the steps confused you, drop a comment and I’ll be happy to help.

如果有任何步骤使您感到困惑,请发表评论,我们将竭诚为您服务。

准备成为专业人士了吗? (Ready to become Pro?)

I have created a free CSS guide to get your CSS skills blazing, immediately. Get the free ebook.

我已经创建了一个免费CSS指南,可让您立即掌握CSS技能。 获取免费的电子书 。

翻译自: https://www.freecodecamp.org/news/how-to-build-a-delightful-loading-screen-in-5-minutes-847991da509f/

愉快的舞会c++

相关文章:

有关C/C++中,表达式计算顺序的问题,以及表达式内部变量“副作用”问题(转)...

经常可以在一些讨论组里看到下面的提问&#xff1a;“谁知道下面C语句给n赋什么值&#xff1f;”m 1; n mm;最近有位不相识的朋友发email给我&#xff0c;问为什么在某个C系统里&#xff0c;下面表达式打印出两个4&#xff0c;而不是4和5&#xff1a;a 4; cout << a &…

HDU 3001

题目中说明每个城市至少要走一次&#xff0c;至多走2次&#xff0c;因此要用到三进制压缩&#xff0c;然后就是状态转移方程了。 这道题就处理三进制的地方麻烦一点。同时注意&#xff0c;在选择最小长度时&#xff0c;一定是要每一个点都经过至少一次的&#xff0c;即是状态的…

微信小程序 侧滑效果实现

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 先看效果图&#xff1a; 源码&#xff1a; <view wx:if{{if_show}} class{{show_centent?"show":"hide"}} /> <button bindtapbtn>展示 or 隐藏&l…

im和音视频开发哪个更好_如何阅读成为更好的开发者的方式

im和音视频开发哪个更好by nolan grace通过诺兰格雷斯 如何阅读成为更好的开发者的方式 (How to read your way to becoming a better developer) If you want to get better at programming, there are two things you need to do:如果您想提高编程水平&#xff0c;则需要做两…

MVC3学习 四 EF删除操作

由于EF的框架是4.1的&#xff0c;所以现在如果想更新部分字段的话&#xff0c;只能从数据库中查出一次数据&#xff08;不用查的方法还没找到&#xff0c;需要继续研究&#xff09;&#xff0c;不能像5.1的版本可以不用查。 更新的Action需要用到[HttpGet]和[HttpPost]&#xf…

ThinkPHP5.0中Redis的使用和封装(原创)

Redis是一种常用的非关系型数据库,主要用作数据缓存,数据保存形式为key-value,键值相互映射.它的数据存储跟MySQL不同,它数据存储在内存之中,所以数据读取相对而言很快,用来做高并发非常不错. ThinkPhP5.0自带了Redis扩展,在使用之前先下载php_redis.dll 网址 http://windows.p…

【微信小程序之画布】四:手指触摸绘波浪线

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 功能&#xff1a;根据手指触摸绘画一条直线路径--> 起点为手指开始触摸时的坐标&#xff0c;终点为手指触摸结束时的坐标 效果图&#xff1a; 上代码&#xff1a; <canvas clas…

saas的计费数据库设计_如何构建和扩展SaaS计费解决方案

saas的计费数据库设计您需要的最低可行产品 (What you need for a Minimum Viable Product) When you are building your Software as a Service (Saas) Minimum Viable Product (MVP), there is a lot of work that needs to be done. It can be difficult to balance this wo…

关于一对多,多对多的多表查询的控制

一、一对多 以班级Classes和学生Student为例&#xff1a;回忆sql语句://内链接,两种方式效果一样,查询的是两边都有的数据SELECT c.*,s.* FROM classes c,student s WHERE s.cidc.cid;SELECT c.cname,s.sname FROM classes c INNER JOIN student s ON s.cidc.cid;//左外连接&am…

JavaScript对象,方括号和算法

by Dmitri Grabov德米特里格拉波夫(Dmitri Grabov) JavaScript对象&#xff0c;方括号和算法 (JavaScript Objects, Square Brackets and Algorithms) One of the most powerful aspects of JavaScript is being able to dynamically refer to properties of objects. In this…

《Java 8 实战》(二)—— Lambda

Lambda表达式可以理解为简洁地表示可传递的匿名函数的一种方式&#xff1a;它没有名称&#xff0c;但它有参数列表/函数主体/返回类型&#xff0c;可能还有一个可以抛出的异常列表。 Lambda表达式由参数/箭头和主体组成&#xff1a; (Apple a1, Apple a2) -> a1.getWeight(…

c++回调函数 callback

&#xff08;1&#xff09;Callback方式Callback的本质是设置一个函数指针进去&#xff0c;然后在需要需要触发某个事件时调用该方法, 比如Windows的窗口消息处理函数就是这种类型。比如下面的示例代码&#xff0c;我们在Download完成时需要触发一个通知外面的事件&#xff1a;…

【微信小程序之画布】终:手指触摸画板实现

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 先看效果图&#xff1a; wxml <!--pages/shouxieban/shouxieban.wxml--> <view class"container"><view>手写板&#xff08;请在下方区域手写内容&…

Android开发中应避免的重大错误

by Varun Barad由Varun Barad Android开发中应避免的重大错误 (Critical mistakes to avoid in Android development) As many pioneers and leaders in different fields have paraphrased:正如许多不同领域的开拓者和领导人所说&#xff1a; In any endeavor, it is import…

机房收费系统(VB.NET)——超具体的报表制作过程

之前做机房收费系统用的报表是GridReport&#xff0c;这次VB.NET重构中用到了VisualStudio自带的报表控件。刚開始当然对这块功能非常不熟悉&#xff0c;只是探究了一段时间后还是把它做出来了。 以下把在VisualStudio&#xff08;我用的是VisualStudio2013&#xff0c;假设与您…

微信小程序实现画布自适应各种手机尺寸

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 解决的问题&#xff1a; 画布&#xff0c;动画等js里面的操作&#xff0c;默认是px而不是rpx, 无法根据手机屏幕自适应 达到的效果&#xff1a; 让画布&#xff0c;动画在不同分辨…

网易新闻首页实现

http://www.2cto.com/kf/201409/330299.html IOS后台运行机制详解&#xff08;二&#xff09; http://blog.csdn.net/enuola/article/details/9148691转载于:https://www.cnblogs.com/itlover2013/p/4403061.html

阿联酋gitex_航空公司网站不在乎您的隐私后续行动:阿联酋航空以以下方式回应我的文章:...

阿联酋gitexby Konark Modi通过Konark Modi 航空公司网站不在乎您的隐私后续行动&#xff1a;阿联酋航空对我的文章进行了全面否认 (Airline websites don’t care about your privacy follow-up: Emirates responds to my article with full-on denial) Yesterday, The Regis…

微信小程序把缓存的数组动态渲染到页面

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 代码实现的目的&#xff1a;当页面销毁的时候&#xff0c;页面的参数状态还是能够保存。 show_img函数实现&#xff1a; 创建一个数组保存到缓存&#xff0c;遍历缓存的list_stutas对…

Find Minimumd in Rotated Sorted Array

二分搜索查最小数&#xff0c;from mid to分别为区间的第一个&#xff0c;中位数&#xff0c;和最后一个数 if(from<mid&&mid<to)//顺序&#xff0c;第一个即为最小值 return from; if(from>mid)//发现逆序&#xff0c;则最小值在这个区间&#xff0c;2分搜索…

在DataTable中更新、删除数据

在DataTable中选择记录 /*在DataTable中选择记录*//* 向DataTable中插入记录如上&#xff0c;更新和删除如下:* ----但是在更新和删除前&#xff0c;首先要找出要更新和删除的记录。* 一种方法是遍历DataRow&#xff0c;搜索想要的记录&#xff0c;* --〉然而更聪明的办法是使用…

使用TensorFlow进行机器学习即服务

by Kirill Dubovikov通过基里尔杜博维科夫(Kirill Dubovikov) 使用TensorFlow进行机器学习即服务 (Machine Learning as a Service with TensorFlow) Imagine this: you’ve gotten aboard the AI Hype Train and decided to develop an app which will analyze the effective…

浏览器加载、解析、渲染的过程

最近在学习性能优化&#xff0c;学习了雅虎军规 &#xff0c;可是觉着有点云里雾里的&#xff0c;因为里面有些东西虽然自己也一直在使用&#xff0c;但是感觉不太明白所以然&#xff0c;比如减少DNS查询&#xff0c;css和js文件的顺序。所以就花了时间去了解浏览器的工作&…

《转》java设计模式--工厂方法模式(Factory Method)

本文转自&#xff1a;http://www.cnblogs.com/archimedes/p/java-factory-method-pattern.html 工厂方法模式&#xff08;别名&#xff1a;虚拟构造&#xff09; 定义一个用于创建对象的接口&#xff0c;让子类决定实例化哪一个类。Factory Method使一个类的实例化延迟到其子类…

微信小程序去除左上角返回的按钮

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 解决方法有两种&#xff1b; 1.把该页面设置为tab页面或者主页 ; 2.进入该页面使用 wx.reLaunch(); 示例 wx.reLaunch({url: ../detail/detail,}) 这样有一个弊端&#xff0c;就是…

我的第一个web_登陆我的第一个全栈Web开发人员职位

我的第一个webby Robert Cooper罗伯特库珀(Robert Cooper) 登陆我的第一个全栈Web开发人员职位 (Landing My First Full Stack Web Developer Job) This is the story of the steps I took to get my first job as a full stack web developer. I think it’s valuable to sha…

HTTP请求报文和HTTP响应报文(转)

原文地址&#xff1a;http://blog.csdn.net/zhangliang_571/article/details/23508953 HTTP报文是面向文本的&#xff0c;报文中的每一个字段都是一些ASCII码串&#xff0c;各个字段的长度是不确定的。HTTP有两类报文&#xff1a;请求报文和响应报文。 HTTP请求报文 一个HTTP请…

微信小程序用户未授权bug解决方法,微信小程序获取用户信息失败解决方法

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; bug示例图&#xff1a; 导致这个bug的原因是 wx.getUserInfo(OBJECT) 接口做了调整&#xff1b; 请看官方文档的描述&#xff1a; wx.getUserInfo(OBJECT) 注意&#xff1a;此接口有…

格式化json日期'/Date(-62135596800000)/'

日期经过json序列化之后&#xff0c;变成了/Date(-62135596800000)/字符串&#xff0c;在显示数据时&#xff0c;我们需要解释成正常的日期。 Insus.NET和js库中&#xff0c;写了一个jQuery扩展方法&#xff1a; $.extend({JsonDateParse: function (value) {if (value /Date(…

aws lambda使用_使用AWS Lambda安排Slack消息

aws lambda使用Migrating to serverless brings a lot of questions. How do you do some of the non-serverless tasks, such as a cronjob in a serverless application?迁移到无服务器带来了很多问题。 您如何执行一些非无服务器的任务&#xff0c;例如无服务器应用程序中的…