How to use CSS Grid layout to implement chicken stamps (with code)
The content of this article is about how to use CSS Grid layout to implement chicken stamps (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. helped.
Effect preview

Source code download
https://github.com/comehope/front-end-daily-challenges
Code Interpretation
Define dom, the container represents the stamp:
<div> </div>
Centered display:
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: teal; }
Set the container size:
.stamp { position: relative; width: 57em; height: 71em; font-size: 5px; padding: 5em; background-color: white; }
Draw with a repeating background The perforations of the stamp:
.stamp { display: flex; flex-direction: column; align-items: center; justify-content: center; } .stamp::after, .stamp::before { content: ''; width: 100%; height: 100%; position: absolute; background: radial-gradient(circle, teal 50%, transparent 50%), radial-gradient(circle, teal 50%, transparent 50%); background-size: 3.5em 3.5em; } .stamp::before { top: 1.5em; background-repeat: repeat-y; background-position: -3% 0, 103% 0; } .stamp::after { left: 1.5em; background-repeat: repeat-x; background-position: 0 -2.5%, 0 102.5%; }
Add the dom element of the chick in the html file. The sub-elements represent the head, beak, body, tail, legs, paws, sun, and orange:
<div> <div> <span></span> <span></span> <span></span> <span></span> <span></span> <span></span> <span></span> <span></span> </div> </div>
Set the row and column dimensions of the grid layout:
.rooster { display: grid; grid-template-columns: 22.5em 13em 1.75em 14.5em 4.5em; grid-template-rows: 12.5em 14.5em 15em 8em 5.5em; background-color: wheat; padding: 2em; margin-top: -2em; }
Draw the fan-shaped head:
.head { grid-column: 4; grid-row: 2; background-color: burlywood; border-top-left-radius: 100%; }
Draw the chick’s eyes and blush on the face:
.head { position: relative; } .head::after { content: ''; position: absolute; width: 2.8em; height: 2.8em; border-radius: 50%; background-color: black; right: 30%; box-shadow: 2em 4em 4em rgba(255, 100, 0, 0.5); }
Draw Fan-shaped beak:
.beak { grid-column: 5; grid-row: 2; height: 4.5em; background-color: darkorange; border-bottom-right-radius: 100%; }
Draw a semicircular body:
.body { grid-column: 2 / 5; grid-row: 3; width: 30em; background-color: saddlebrown; border-radius: 0 0 15em 15em; }
Use pseudo elements to draw wings through shadows:
.body { position: relative; overflow: hidden; } .body::after { content: ''; position: absolute; width: 20em; height: 10em; border-radius: inherit; box-shadow: 4em 2em 4em rgba(0, 0, 0, 0.3); left: calc((30em - 20em) / 2); }
Draw a fan-shaped tail:
.tail { grid-column: 1; grid-row: 1 / 3; height: 22.5em; background-color: burlywood; align-self: end; border-top-left-radius: 100%; }
Draw a fan-shaped leg:
.leg { grid-column: 4; grid-row: 4; width: 8em; background-color: burlywood; border-bottom-right-radius: 100%; }
Draw a fan-shaped paw:
.foot { grid-column: 4; grid-row: 5; width: 5.5em; background-color: darkorange; border-top-right-radius: 100%; }
Draw a semicircular sun:
.sun { grid-column: 3 / 5; grid-row: 1; width: 17em; --h: calc(17em / 2); height: var(--h); background-color: darkorange; border-radius: 0 0 var(--h) var(--h); }
Draw Round oranges and semicircular leaves. Note that the way of drawing the leaves here is different from the way of drawing the semicircles before:
.orange-stuff { grid-column: 1; grid-row: 3 / 6; width: 16em; height: 16em; background-color: darkorange; align-self: end; justify-self: end; border-radius: 50%; position: relative; } .orange-stuff::before { content: ''; position: absolute; width: 8em; height: 8em; background: linear-gradient(45deg, transparent 50%, saddlebrown 50%); border-radius: 50%; top: -6.8em; left: 10%; }
Add some more text to the dom, including title, author and face value :
<div> <div> <!-- 略 --> </div> <p> <span>Rooster</span> <span>comehope</span> <span>120</span> </p> </div>
Set the text style of the title:
.text { position: relative; width: calc(100% + 2em * 2); height: 6em; font-family: sans-serif; } .text .title { position: absolute; font-size: 6em; font-weight: bold; color: brown; }
Set the text style of the author:
.text .author { position: absolute; font-size: 3em; bottom: -1.2em; color: dimgray; }
Set the text style of the face value:
.text .face-value { position: absolute; font-size: 14em; right: 0; line-height: 0.9em; color: darkcyan; }
You’re done!
The above is the detailed content of How to use CSS Grid layout to implement chicken stamps (with code). For more information, please follow other related articles on the PHP Chinese website!

There's been a run of tools, articles, and resources about color lately. Please allow me to close a few tabs by rounding them up here for your enjoyment.

Robin has covered this before, but I've heard some confusion about it in the past few weeks and saw another person take a stab at explaining it, and I wanted

I absolutely love the design of the Sandwich site. Among many beautiful features are these headlines with rainbow underlines that move as you scroll. It's not

Many popular resume designs are making the most of the available page space by laying sections out in a grid shape. Let’s use CSS Grid to create a layout that

Page reloads are a thing. Sometimes we refresh a page when we think it’s unresponsive, or believe that new content is available. Sometimes we’re just mad at

There is very little guidance on how to organize front-end applications in the world of React. (Just move files around until it “feels right,” lol). The truth

Most of the time you don’t really care about whether a user is actively engaged or temporarily inactive on your application. Inactive, meaning, perhaps they

Wufoo has always been great with integrations. They have integrations with specific apps, like Campaign Monitor, Mailchimp, and Typekit, but they also


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

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.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools