Wednesday, May 14, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

How to Create CSS Ribbon Shapes with a Single Element — SitePoint

September 28, 2023
in Cloud & Programming
Reading Time: 3 mins read
0 0
A A
0
Share on FacebookShare on Twitter



In this article, I will demonstrate how to use modern CSS tricks to create visually appealing CSS ribbon shapes with minimal code. These ribbons will also have hover animations. Unlike traditional CSS ribbons, which often rely on fixed dimensions and complex calculations, the ribbons we will create here use a single element and CSS variables for easy customization. The shapes will automatically adjust to fit their content, eliminating the need to manually adjust text sizing.

To begin, let’s define the variables for our folded ribbon shape:

“`html

“`

Next, we’ll utilize the `clip-path` property to create the folded shape. The `clip-path` property allows us to define a polygon shape to clip the element. We’ll also add some padding to ensure the text is not cut off. Here’s the updated code:

“`html

“`

We’ll also use the `lh` unit, which represents the line-height value, to ensure the shape adjusts based on the content. The `1lh` value represents the height of the element.

To create the folded part, we’ll update the `clip-path` property to include additional points that extend outside the element. We’ll use a box-shadow to make these hidden parts visible. Here’s the updated code:

“`html

“`

Finally, we’ll add a gradient and additional box-shadow to create a shadow effect for the ribbon shape.

To create the second ribbon shape (the green one), we’ll follow a similar approach but with a different polygon shape. We’ll invert the polygon of the first ribbon to achieve the desired shape.

To add hover animations to the ribbons, we’ll update the polygon on hover by offsetting certain points. We’ll define a CSS variable to control the offset and update it on hover. This will create the illusion of movement. Here’s the code:

“`html

“`

For the second shape, we’ll use trigonometric functions, CSS variables, and the `calc()` function to achieve the desired shape. We’ll also utilize pseudo-elements to create additional elements and apply transformations and clip-paths to achieve the desired effect. The code for the second shape is more complex and involves more calculations, but the principle remains the same: use CSS variables to control the shape and apply transformations and clip-paths to achieve the desired result.

By following these steps, you can create visually appealing CSS ribbon shapes with minimal code and add hover animations for an extra touch of interactivity.



Source link

Tags: CreatecssElementRibbonShapesSingleSitePoint
Previous Post

Building Better ML Systems — Chapter 4. Model Deployment and Beyond | by Olga Chernytska | Sep, 2023

Next Post

Micron’s mixed guidance weighs on shares but analysts see pullback as a buying opportunity By Investing.com

Related Posts

Top 20 Javascript Libraries You Should Know in 2024
Cloud & Programming

Top 20 Javascript Libraries You Should Know in 2024

June 10, 2024
Simplify risk and compliance assessments with the new common control library in AWS Audit Manager
Cloud & Programming

Simplify risk and compliance assessments with the new common control library in AWS Audit Manager

June 6, 2024
Simplify Regular Expressions with RegExpBuilderJS
Cloud & Programming

Simplify Regular Expressions with RegExpBuilderJS

June 6, 2024
How to learn data visualization to accelerate your career
Cloud & Programming

How to learn data visualization to accelerate your career

June 6, 2024
BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager
Cloud & Programming

BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager

June 6, 2024
Copilot Studio turns to AI-powered workflows
Cloud & Programming

Copilot Studio turns to AI-powered workflows

June 6, 2024
Next Post
Micron’s mixed guidance weighs on shares but analysts see pullback as a buying opportunity By Investing.com

Micron's mixed guidance weighs on shares but analysts see pullback as a buying opportunity By Investing.com

How to Improve Your Instagram Results: Small Changes With Big Impacts

How to Improve Your Instagram Results: Small Changes With Big Impacts

Tanzu Mission Control Self-Managed Now Available for Cloud Services Providers and Sovereign Cloud Providers

Tanzu Mission Control Self-Managed Now Available for Cloud Services Providers and Sovereign Cloud Providers

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

May 19, 2024
How To Build A Quiz App With JavaScript for Beginners

How To Build A Quiz App With JavaScript for Beginners

February 22, 2024
Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

December 6, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In