日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > CSS >内容正文

CSS

css 跳动的心_如何用纯CSS为您的情人打造一颗跳动的心

發(fā)布時間:2023/11/29 CSS 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 css 跳动的心_如何用纯CSS为您的情人打造一颗跳动的心 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

css 跳動的心

Each year on February 14th, many people exchange cards, candies, gifts or flowers with their special “valentine”. The day of romance we call Valentine’s Day is named for a Christian martyr and dates back to the 5th century, but has origins in the Roman holiday Lupercalia.

每年2月14日,許多人都用他們特殊的“情人節(jié)”來交換卡片,糖果,禮物或鮮花。 我們稱之為情人節(jié)的浪漫之日以基督教烈士而命名,其歷史可以追溯到5世紀(jì),但起源于羅馬假日盧佩卡利阿(Lupercalia)。

Ok so far so good. But what can a programmer do for their Valentine?

好的,到目前為止很好。 但是程序員可以為他們的情人做什么?

My answer is: use CSS and be creative!

我的答案是:使用CSS并發(fā)揮創(chuàng)造力!

I really love CSS. It’s not a really sophisticated language (it’s not even considered a programming language most of the time). But with some geometry, mathematics and some basic CSS rules, you can turn your browser into a canvas of your creativity!

我真的很喜歡CSS。 它不是一種真正復(fù)雜的語言(大多數(shù)時候甚至都不被視為編程語言)。 但是,有了一些幾何,數(shù)學(xué)和一些基本CSS規(guī)則,您就可以將瀏覽器變成具有創(chuàng)造力的畫布!

So let’s start. How would you create a heart with pure Geometry?

因此,讓我們開始吧。 您將如何創(chuàng)建具有純幾何形狀的心臟?

You just need a square and two circles. Right?

您只需要一個正方形和兩個圓圈。 對?

And we can draw that with a single element, thanks to the ::after and ::before pseudo elements. Speaking about pseudo elements, ::after is a pseudo element which allows you to insert content into a page from CSS (without it needing to be in the HTML). ::before is exactly the same, only it inserts the content before any other content in the HTML instead of after.

而且,由于::after和::before偽元素,我們可以使用單個元素進行繪制。 說到偽元素, ::after是一個偽元素,它允許您將內(nèi)容從CSS插入頁面(無需在HTML中插入)。 ::before完全相同,只是它在HTML中的其他任何content之前而不是after之后插入content 。

For both pseudo elements, the end result is not actually in the DOM, but it appears on the page as if it would be.

對于這兩個偽元素,最終結(jié)果實際上不在DOM中,但它看起來像在頁面中一樣。

So let’s create our heart.

因此,讓我們創(chuàng)建自己的心。

.heart {background-color: red;display: inline-block;height: 50px;margin: 0 10px;position: relative;top: 0;transform: rotate(-45deg);position: absolute; left: 45%; top: 45%;width: 50px; }.heart:before, .heart:after {content: "";background-color: red;border-radius: 50%;height: 50px;position: absolute;width: 50px; }.heart:before {top: -25px;left: 0; }.heart:after {left: 25px;top: 0; }

You can easily notice that we define the square and its positioning by using the main ‘heart’ class and the two circles with the ::before and ::after pseudo elements. The circles are actually just 2 more squares that have their border-radius reduced to the half.

您可以輕松地注意到,通過使用主要的“心臟”類以及帶有::before和::after偽元素的兩個圓,我們定義了正方形及其位置。 圓圈實際上只是另外2個正方形,其邊界半徑減小了一半。

But what is a heart without beating?

但是沒有跳動的心是什么?

Let’s create a pulse. Here we are going to use the @keyframes rule. The @keyframes CSS at-rule is used to define the behaviour of one cycle of a CSS animation.

讓我們創(chuàng)建一個脈沖。 在這里,我們將使用@keyframes規(guī)則。 @keyframes CSS規(guī)則用于定義CSS動畫一個周期的行為。

When we are using the keyframes rule, we can divide a time period to smaller parts and create a transformation/animation by splitting it into steps (each step corresponds to a percentage of the completion of the time period).

當(dāng)使用關(guān)鍵幀規(guī)則時,我們可以將時間段劃分為較小的部分,并通過將其分成多個步驟來創(chuàng)建轉(zhuǎn)換/動畫(每個步驟對應(yīng)于該時間段完成的百分比)。

So let’s create the heartbeat. Our heartbeat animation consists of 3 steps:

因此,讓我們創(chuàng)建心跳。 我們的心跳動畫包括3個步驟:

@keyframes heartbeat {0% {transform: scale( 1 ); }20% {transform: scale( 1.25 ) translateX(5%) translateY(5%);} 40% {transform: scale( 1.5 ) translateX(9%) translateY(10%);} }
  • On 0% of the time period we start with no transformation.

    在0%的時間段內(nèi),我們不進行任何轉(zhuǎn)換。
  • On 20% of the time period we scale our shape to 125% of its initial size.

    在20%的時間段內(nèi),我們將形狀縮放到其初始大小的125%。
  • On 40% of the time period we scale our shape to 150% of its initial size.

    在40%的時間段內(nèi),我們將形狀縮放到其初始大小的150%。
  • For the remaining 60% of the time period we leave time for our heart to return to its initial state.

    在剩下的60%的時間里,我們有時間讓心臟恢復(fù)到初始狀態(tài)。

    Finally we have to assign the animation to our heart.

    最后,我們必須將動畫分配給我們。

    .heart {animation: heartbeat 1s infinite; // our heart has infinite heartbeat :)... }

    That’s it!

    而已!

    We have a beating heart that will beat forever.Or maybe as long as your own love lasts…

    我們有一顆跳動的心,它將永遠跳動。或者也許只要你自己的愛持續(xù)下去……

    Feel free to check out the related Codepen:

    隨時查看相關(guān)的Codepen:

    I wish you a wonderful Valentine’s day!

    祝您情人節(jié)快樂!

    翻譯自: https://www.freecodecamp.org/news/how-to-create-a-beating-heart-with-pure-css-for-your-valentine-2aeb05e2d36e/

    css 跳動的心

    總結(jié)

    以上是生活随笔為你收集整理的css 跳动的心_如何用纯CSS为您的情人打造一颗跳动的心的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 国产精品视频一区二区三区不卡 | 一区二区传媒有限公司 | 总裁边开会边做小娇妻h | 草草网址 | k8经典成人理伦片 | 很黄很污的视频网站 | 97麻豆视频 | 欧美日韩国产一区二区三区在线观看 | 乱色欧美 | 久久久在线免费观看 | 国产午夜无码精品免费看奶水 | 欧美青草视频 | 91视频污在线观看 | 夜夜躁很很躁日日躁麻豆 | 日韩午夜电影网 | 快射视频网站 | 日韩精品一级 | 欧美丝袜脚交 | 国产一二三在线观看 | 中文字幕成人av | 主播一区二区 | 麻豆视频在线 | 成人深夜福利在线观看 | 在线视频观看你懂得 | 欧美脚交视频 | av网站大全在线观看 | 日韩人妻无码一区二区三区 | 欧美日韩人妻精品一区二区三区 | 午夜影视网| 午夜激情网 | 卡一卡二视频 | 婷婷在线免费视频 | 伊人青青 | 国产原创视频在线观看 | 高清国产午夜精品久久久久久 | 上原亚衣在线 | 亚洲成人网在线播放 | 亚洲va欧美va国产综合久久 | www国产亚洲精品久久麻豆 | 夜间福利在线 | 国产精品99久久久久久久 | 欧美人吸奶水吃奶水 | 99久久网站 | 377p粉嫩大胆色噜噜噜 | 神马久久影院 | 韩日欧美| 97夜夜 | 欧美午夜久久 | 91av网址| 韩国女主播一区 | 美女被出白浆 | 国产专区一区二区三区 | 国产又粗又硬又黄的视频 | 国产传媒中文字幕 | 欧美日韩亚洲二区 | 午夜精品少妇 | 超碰伊人久久 | 欧美a级免费 | 欧美三日本三级少妇三级99观看视频 | 欧美在线性视频 | 影音先锋欧美资源 | 久久亚洲色图 | 91婷婷| 日本老小玩hd老少配 | 中文字幕有码视频 | 午夜色大片 | 成人玩具h视频 | 日本黄网站色大片免费观看 | 欧美日韩精 | www.色妞| 亚洲精品乱码久久久久久自慰 | 亚洲国产精品人人爽夜夜爽 | 激情久久五月 | 国产噜噜噜噜久久久久久久久 | 国产一区二区在线看 | 中文字幕在线视频一区二区三区 | 少妇被躁爽到高潮无码人狍大战 | 亚洲精品日产精品乱码不卡 | 欧美视频导航 | 久久久久噜噜噜亚洲熟女综合 | 久色影视 | 色欧洲| 麻豆免费看片 | 日本japanese乳偷乱熟 | 久久久6| 色一区二区三区四区 | 丁香婷婷视频 | 色涩av| 亚洲黄色三级 | 98超碰在线| 久久精品无码一区二区三区 | 亚洲精品久久久久久国 | 影音先锋三级 | 四虎影库永久在线 | 在线观看免费av网站 | 久久人人爽爽人人爽人人片av | 伊人tv| 亚洲无av在线中文字幕 | 日韩黄色影视 |