search
HomeWeb Front-endCSS TutorialTake 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.

Take you step by step to draw a cute cartoon lion animation using CSS

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:

Take you step by step to draw a cute cartoon lion animation using CSS

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%);
}

Take you step by step to draw a cute cartoon lion animation using CSS

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

border

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;
}

TailThe tail is mainly implemented using border

, draw a rectangular div block, let He rotated it at an angle, then drew just one of the borders, and then used

border-radius: 40% 50%Take you step by step to draw a cute cartoon lion animation using CSS 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 tailTake you step by step to draw a cute cartoon lion animation using CSS

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.

keywordvalue

##left##50%rightThe second parameter represents the definition The offset value of the deformation center from the top of the box model. keyword
0%
center
##100%
value

##top

0%center
##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);
  }
}

Take you step by step to draw a cute cartoon lion animation using CSS

眨眼睛

眼睛一眨一眨会显得狮子会更生动,但是如果通过缩小高度做动画实现的画,会显得非常难看因为连眼白眼珠都会压缩变形。所以我们依然是通过 clip-path 属性,利用 ellipse 方法把裁剪范围从顶部和底部往中间延伸,直至2%留一道缝隙即可。

.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%);
  }
}

Take you step by step to draw a cute cartoon lion animation using CSS

看简简单单的几段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!

Statement
This article is reproduced at:掘金社区. If there is any infringement, please contact admin@php.cn delete
Next Level CSS Styling for CursorsNext Level CSS Styling for CursorsApr 23, 2025 am 11:04 AM

Custom cursors with CSS are great, but we can take things to the next level with JavaScript. Using JavaScript, we can transition between cursor states, place dynamic text within the cursor, apply complex animations, and apply filters.

Worlds Collide: Keyframe Collision Detection Using Style QueriesWorlds Collide: Keyframe Collision Detection Using Style QueriesApr 23, 2025 am 10:42 AM

Interactive CSS animations with elements ricocheting off each other seem more plausible in 2025. While it’s unnecessary to implement Pong in CSS, the increasing flexibility and power of CSS reinforce Lee's suspicion that one day it will be a

Using CSS backdrop-filter for UI EffectsUsing CSS backdrop-filter for UI EffectsApr 23, 2025 am 10:20 AM

Tips and tricks on utilizing the CSS backdrop-filter property to style user interfaces. You’ll learn how to layer backdrop filters among multiple elements, and integrate them with other CSS graphical effects to create elaborate designs.

SMIL on?SMIL on?Apr 23, 2025 am 09:57 AM

Well, it turns out that SVG's built-in animation features were never deprecated as planned. Sure, CSS and JavaScript are more than capable of carrying the load, but it's good to know that SMIL is not dead in the water as previously

'Pretty' is in the eye of the beholder'Pretty' is in the eye of the beholderApr 23, 2025 am 09:40 AM

Yay, let's jump for text-wrap: pretty landing in Safari Technology Preview! But beware that it's different from how it works in Chromium browsers.

CSS-Tricks Chronicles XLIIICSS-Tricks Chronicles XLIIIApr 23, 2025 am 09:35 AM

This CSS-Tricks update highlights significant progress in the Almanac, recent podcast appearances, a new CSS counters guide, and the addition of several new authors contributing valuable content.

Tailwind's @apply Feature is Better Than it SoundsTailwind's @apply Feature is Better Than it SoundsApr 23, 2025 am 09:23 AM

Most of the time, people showcase Tailwind's @apply feature with one of Tailwind's single-property utilities (which changes a single CSS declaration). When showcased this way, @apply doesn't sound promising at all. So obvio

Feeling Like I Have No Release: A Journey Towards Sane DeploymentsFeeling Like I Have No Release: A Journey Towards Sane DeploymentsApr 23, 2025 am 09:19 AM

Deploying like an idiot comes down to a mismatch between the tools you use to deploy and the reward in complexity reduced versus complexity added.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!