Take you step by step to draw a cute cartoon lion animation using CSS
How to draw lion animation using CSS? The following article will take you step by step to draw a cute cartoon lion animation using CSS. I hope it will be helpful to you.
In this issue, we are going to use pure CSS to draw a cute and cute cartoon lion. Through this chestnut, we can become familiar with more CSS drawing techniques. I believe that in the future interface More comfortable in drawing tasks. [Recommended learning: css video tutorial]
Demonstration
Text
Basic drawing
Let’s first look at the parts of Kangkang’s lion:
Through the above view, this lion is composed of ears eyes nose beard mouth mane front legs claws tail
these parts. I believe it is not difficult for everyone to see that many parts can be completed by simply making rectangles and rounded corners. For example, eyes are formed by stacking two circles. You can see the code demonstration above for details. I won’t go into too much detail about these basic graphics here.
Next, let’s talk about some graphics that are difficult to draw in detail.
EAR
You can see that it looks like a semicircle, like petals. It is definitely not easy to do it with conventional methods, but it can be done by clip-path
attribute, which uses clipping to create a displayable area of the element. Parts within the area are displayed and parts outside the area are hidden. To draw the ears, we use this area to crop. For the ellipse
method of elliptical cropping, the two passed in represent the radius of the cropping, and the two values after at represent the cropping. The coordinates of the x and y axes.
.ear { width: 70px; height: 70px; position: absolute; top: 10px; background-color: var(--skin-color); z-index: 9; border-radius: 40px; clip-path: ellipse(100% 100% at -20% -10%); }
Similarly, the body similar to a semicircle is also achieved through clip-path: ellipse
. Of course, he can cut more than this. Any graphics can be said to be very powerful. Nose # Set to 0, simply use the
attribute to complete, set border-width to replace the width and height of the block, but the inside of the block is made up of four small triangles It is a rectangle, and because the arrangement is in the order of top, right, bottom, and left, a triangle can be realized by assigning a color to one of the corners.
.nose { width: 0px; height: 0px; border-width: 20px 30px; border-style: solid; border-color: var(--eye-color) transparent transparent transparent; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin-top: 40px; z-index: 3; }
Tail
The tail is mainly implemented using
border
border-radius: 40% 50% to give it a curved feel and he was done.
.tail { width: 320px; height: 320px; position: absolute; top: -137px; border-style: solid; border-width: 30px; border-radius: 40% 50%; border-color: transparent var(--tail-color) transparent transparent; transform: rotate(125deg); left: -180px; }
Animation production
wagging tail
The power of the tail originates from the root of the tail, so a slight swinging rotation animation needs to be performed from the root. Therefore, we use the transform-origin attribute, which allows you to change the origin of an element's transformation, such as , when the root exerts force, set it directly to transform-origin: 50% 100% or it can be written as
transform-origin: center bottom. The first parameter represents the offset value that defines the deformation center from the left side of the box model.
keyword
value
0% | |
---|---|
center
| ##50%
|
##100% |
|
| keywordvalue |
##top
##50%
|
bottom |
100%
|
<p>后面的动画微微的旋转偏移就看下方的代码块了,非常简单只需要微调一些角度和偏移即可。这里再多补充一句,<code>transform 的变换必须是盒模型定位的元素哦。.tail { // ... animation: 1s wagging ease-in-out infinite alternate forwards; transform-origin: 50% 100%; } @keyframes wagging { 0% { transform: rotate(125deg) translateX(0) translateY(0px); } 100% { transform: rotate(130deg) translateX(15px) translateY(-15px); } } 眨眼睛 眼睛一眨一眨会显得狮子会更生动,但是如果通过缩小高度做动画实现的画,会显得非常难看因为连眼白眼珠都会压缩变形。所以我们依然是通过 .eye { // ... animation: 4s blinking infinite forwards; overflow: hidden; } @keyframes blinking { 0%, 40%, 80% { clip-path: ellipse(100% 100% at 50% 48%); } 60%, 100% { clip-path: ellipse(100% 2% at 50% 48%); } } 看简简单单的几段css代码就让一只灵动乖巧的狮子就坐在你的面前,赶紧尝试一下吧~ (学习视频分享:web前端) |
The above is the detailed content of Take you step by step to draw a cute cartoon lion animation using CSS. For more information, please follow other related articles on the PHP Chinese website!

What it looks like to troubleshoot one of those impossible issues that turns out to be something totally else you never thought of.

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

I know, I know: there are a ton of content management system options available, and while I've tested several, none have really been the one, y'know? Weird pricing models, difficult customization, some even end up becoming a whole &

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
