惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Stack Overflow Blog
Stack Overflow Blog
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
腾讯CDC
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
L
LINUX DO - 热门话题
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
C
Cisco Blogs
A
Arctic Wolf
Latest news
Latest news
Jina AI
Jina AI
P
Proofpoint News Feed
博客园 - 叶小钗
Vercel News
Vercel News
T
Threat Research - Cisco Blogs
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
C
Check Point Blog
H
Heimdal Security Blog
博客园 - Franky
小众软件
小众软件
The Register - Security
The Register - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
Project Zero
Project Zero
G
GRAHAM CLULEY
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Scott Helme
Scott Helme
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU

ImageKit.io Blog

Next.js Image Optimization with ImageKit Use Video as a Background in Your Next.js Project How to Fix Autoplay Video in Next.js How Durian Scaled a Visual-First Retail Experience to 350K Monthly Visitors Online How Matsmart accelerated image delivery across countries with ImageKit AI in Digital Asset Management: From Smart Workflows to Agentic Automation How Joseph Joseph unified and secured global video delivery with ImageKit How Modall powers fast, effortless media delivery across 40+ projects with ImageKit Digital Asset Management (DAM) Trends: 2026 Report How to add a poster image to Video.js player (and automate it) HLS streaming with Video.js + React Building the future of storytelling with fast, AI-powered video delivery How PushOwl delivers 100M+ image-rich notifications seamlessly with ImageKit How Homify delivers millions of interior design images seamlessly with ImageKit Better event discovery with lightning‑fast videos & images Adding video player in React Native Video player in Angular applications Crop and resize videos in React Next.js image and video upload React image and video upload React video optimization How we quadrupled our traffic to 625K monthly page views How Apollo 24|7 boosted performance & reduced costs with ImageKit Simplify your media workflows with ImageKit DAM integrations Extending Lighthouse for custom image and video optimization analysis Brand Asset Management: What is it? How does it work? WordPress Digital Asset Management Guide - Manage your WP media assets better Why Shopify retailers need a digital asset management solution DAM vs. SharePoint: Which is best for you? AI-powered Metadata and Tagging in Digital Asset Management How Hopscotch built India's largest online Kids' fashion brand with ImageKit Dropbox Vs. DAM: Which Is The Right Tool For Digital Asset Management Digital Asset Management for Photographers: A Complete Guide Why digital asset management for agencies is essential Helping both Top and Bottom Line: SaffronStays rapid, profitable growth with ImageKit How KreditBee simplified media experiences with ImageKit Google Drive alternatives for businesses (with fast-growing teams) Node.js image upload ImageKit: The Secret Ingredient in Swiggy’s Expansion Journey Streamlining the Design Approval Process: A Comprehensive Guide AV1 Codec - Complete guide for video application devs PHP image and video upload Angular image & video upload AV1 vs VP9: Which codec should you choose? Adding video player in Next.js React Video Player VP8 vs VP9 - In the context of online video delivery Exploring WebM vs MP4 7 Free Digital Asset Management Software that are not Open-Source Comparing 9 Top Digital Asset Management Tools in the Market What are Brand Standards and Why do they Matter? Boost Sales and Brand Appeal: Essential Tips for eCommerce Image Management Brand Recall: The Strategy to Create Unforgettable Brands How to upload files in HTML? Branding for Small Businesses (2025 Edition) Everything you need to know about VP9 codec Recent updates from ImageKit and what's next Best Ways to Write RFP For Digital Asset Management (+ with free RFP template) What is Brand Dilution? How to Avoid It? Explained with [Examples] The Importance of Brand Identity: Leveraging Digital Asset Management for Impact From Launch to Scale: How to Launch a Brand Campaign Digital Asset Management Requirements - What do You Need to Evaluate and How? Marketing Collateral Management: A Quick End-to-End Guide Video Content Management System: What Is It And How To Choose One? Dropbox vs. Google Drive vs. Onedrive: The Best Cloud Storage Solution How to Build Brand Trust: Get Started In 2025 Google Drive vs. Box: A Detailed Comparison How Digital Asset Management Solutions Help Protect Brand Equity A DAM Solution Can Safeguard Your Digital Intellectual Property - Here’s How WebP Vs. PNG: Which Image Format Should You Use and Why? How to Resize Images in Bootstrap Easily Progressive jpegs (PJPEG): the key to loading images faster on your website Dropbox vs. Google Drive: The Best Cloud Storage For Digital Assets Dropbox Pros & Cons In 2024: An In-Depth Analysis and Why A DAM Solution Stands Out Google Drive Vs OneDrive: The Better Storage Option For Digital Assets Manage your video assets better with video metadata Understanding DAM's Role in Strengthening Brand Identity Digital asset management strategy: What to know before creating one The Ultimate Guide To Marketing Agency Onboarding 6 Solutions To Simplify Large File Sharing Over The Web A Step-by-Step Breakdown of a Video Production Workflow 13 Digital Asset Management Use Cases You Should Know How to Conduct a Brand Audit and Manage Your Brand Assets Costly Consequences of Inconsistent Branding And How DAM Can Help Dynamic Asset Transformation: What It Is, Why You Need It, and How ImageKit Can Help Everything You Need to Know About HTML Video Autoplay How To Select Your DAM Vendor: A Complete Guide How to Boost User Experience with Smart Digital Asset Management React Image Optimization: A Guide for Web Developers Why Should DAM Be A Part Of Your MarTech Stack? Unleashing the Power of Content Repurposing with ImageKit MKV vs MP4: Which Video File Format Is Better for Your Needs? Digital Asset Management For Ecommerce: A Complete Guide How an Image Tagging Software can Transform Your Image Search How to Manage Your Content Lifecycle Effectively M4V vs MP4: Which Video Format Should You Use and Why? Why Every Business Needs An Image Management System All The Questions To Ask During A Dam Demo Which is the Best Image Format for Your Website? Uploading Multiple Files Using JavaScript: A Comprehensive Guide
CSS image overlay
Manu Chaudhary · 2021-06-14 · via ImageKit.io Blog

Image overlay is the technique of adding text or images over another base image. One of the simplest ways to add image or text overlay is using CSS properties and pseudo-elements.

In short, CSS overlay effects are achieved by using the following:

  • background-image and background CSS properties to add image and linear-gradient overlay effect.
  • position:absolute, top, bottom, right, left CSS properties to control the position of overlay image or text.
  • ::after and ::before CSS pseudo-elements along with content CSS property to control the content in case of text overlay.

Here is an excellent example of overlay effect from the Airbnb website.

Example of text overlay from Airbnb.
Example of text overlay from Airbnb.

In the above example, two text snippets (The Greatest Outdoors and Wishlist curated by Airbnb) and one CTA (Get inspired) were added on top of a base image.

In this post, we will learn how to create similar image overlay effects.

There are two types of overlay:

  1. Image overlay - Adding image over an image, e.g., watermarked images where you see a logo on top of an image.
  2. Text overlay - Adding text over an image, e.g., hero images, marketing banners like above Airbnb example.

More specifically, we will talk about two techniques to create image overlay:

  1. Text and image overlay using CSS

    We will cover examples and code of how to add text overlay and image overlay using CSS. You can use these techniques on your website by copy-pasting code snippets provided in this post.

    ? This method is easy to understand and use.

    ? If the user downloads the image, they won't see the overlay effects.

    ? You will have to write separate code for desktop, mobile, iOS, and Android applications.

    Quick links:
    → Text overlay examples
    → Image overlay examples

  2. (Recommended) Text overlay, image overlay, and visual effects using ImageKit.io

    Here we will talk about how to simplify text and image overlay generation. We will create visual effects just by changing URL parameters, i.e., src of image.

    This will allow you to use the same image across desktop, mobile, iOS, and Android applications. You won't have to write extra markup or code to achieve overlay effects in different platforms.

    ? Pre-generated images are rendered quickly on the client side.

    ? The same image URL works on mobile, desktop, iOS, and Android app.

    ? Not as powerful as native CSS and HTML but good for 90% use-case.

    Quick links:
    → Simple text overlay using ImageKit.io
    → E-commerce product images labels
    → Watermark images
    → Dynamic marketing banners

Text overlay effects using CSS

Text overlay using a vanilla div element

We will add a text on top of the following base image:

https://ik.imagekit.io/ikmedia/accessories_banner.jpg?tr=w-1200,h-400

Base image
Base image

tr=w-1200,h-400 is used to resize the image for this example using ImageKit.io.

We will add a text in the div element with class overlay. This is useful if the text is dynamic and coming from the backend as part of the initial HTML.

The HTML will look like:

<div class="example">
  <img  class="background-image" src="https://ik.imagekit.io/ikmedia/accessories_banner.jpg?tr=w-1200,h-400">
  <div class="overlay">
    Multi-line <br/>text
  </div>
</div>

We want this text to be placed on top of the image. Let's set the positive:absolute for div with class name overlay. And use top and right CSS property to control the position of this overlay text relative to the background image. The final CSS looks like this:

.example img {
  width: 100%;
  position: relative;
}

.example .overlay {
  position: absolute;
  top: 80px;
  right: 15px;
  font-weight: bold;
  text-align: right;
  font-size: 30px;
}

The final result:

<iframe width="100%" height="300" src="//jsfiddle.net/imagekit_team/7weapfkd/10/embedded/result,html,css/dark/" allowfullscreen="allowfullscreen" allowpaymentrequest="" frameborder="0">``</iframe>

Text overlay using CSS pseudo-element

We can also use ::after or ::before CSS pseudo-elements instead of creating a new div element. This means all the text will be stored in the CSS only. This solution is helpful if you want to overlay a fixed set of labels in multiple places on the website.

<iframe width="100%" height="300" src="//jsfiddle.net/imagekit_team/yh3vpqbj/52/embedded/css,html,result/dark" allowfullscreen="allowfullscreen" allowpaymentrequest="" frameborder="0">``</iframe>

Image overlay effects using CSS

Just like we added text on top of images, we can also add images over other images using native CSS properties.

Image gradient overlay effect

The gradient overlay effect is one of the commonly used overlay effects that you will see on landing pages.

Let's create the hero section of a landing page using the following hero image as background.

https://ik.imagekit.io/ikmedia/blog/hero-image.jpeg

Sample hero image
Sample hero image

The HTML looks like:

<header>
    <section class='hero-header'>
        <h1>Hero title</h1>
        <h2>Another landing page</h2>
        <button>Sign-up</button>
    </section>
</header>

We will use the background CSS property to create a linear gradient overlay effect over an image.

header {
    height: 400px;
    width: 100%;
    text-align: center;
    padding-top: 100px;
    color: white;
    overflow: hidden;
    background: #C04848;  /* fallback for old browsers */
    background: linear-gradient(rgb(72,0,72,0.8), rgb(192,72,72,0.8)), url("https://ik.imagekit.io/ikmedia/blog/hero-image.jpeg");  /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(rgb(72,0,72,0.8), rgb(192,72,72,0.8)), url("https://ik.imagekit.io/ikmedia/blog/hero-image.jpeg"); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    background-size: cover;
    background-repeat: no-repeat;
}

This will create a beautiful gradient overlay effect that you can use on your landing pages.

<iframe width="100%" height="500" src="//jsfiddle.net/imagekit_team/Lo16fr82/52/embedded/result,html,css/dark/" allowfullscreen="allowfullscreen" allowpaymentrequest="" frameborder="0">``</iframe>

If you are looking for more awesome images effect check out our guide on CSS Image Effects to nail your images!

Downsides of CSS image overlay using CSS

While creating image and text overlay effects using native CSS is pretty easy, it has some downsides.

  • If the user saves the image or opens it in a new tab, they won't see the text or image that you added using CSS.
  • You will have to write extra markup to generate these effects.
  • The same code won't work for iOS and Android.

To overcome these problems, you can generate text and image overlay using an image CDN like ImageKit.io.

Overlay using ImageKit.io

ImageKit.io is an image CDN that allows you to resize, crop, rotate, change image format, add text, and image overlay using URL parameters. It also takes care of image optimization and serving assets using a global CDN.

You will need an ImageKit.io account to generate text and image overlays. Create a free account on ImageKit.io if you don't already have one. ImageKit.io offers a generous free plan that gives you up to 20GB of bandwidth, absolutely FREE, every month!

Let's dive into some examples.

Simple text overlay using ImageKit.io

Original image URL:
https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg

Now using text overlay layer,

  • Let's add a text overlays made easy with font size 45px and black color #000000. We will use l-text,i-overlays made easy,fs-45,co-000000,l-end, parameter in the URL.
  • With a transparent white background i.e. #FFFFFF80. We will add bg-FFFFF80 parameter in the URL.
  • With padding of 40px using pa-40 parameter.

The final URL becomes:

https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg?tr=l-text,i-overlays made easy,fs-45,co-000000,bg-FFFFFF80,pa-40,l-end

The result image:

In this blog, we will cover a few examples. But you can learn about all the parameters from the text overlay layer documentation.

E-commerce use-case

You will often see specific promotional or information labels on the product image on an e-commerce website like this.

Sample E-commerce product listing page
Sample E-commerce product listing page

With ImageKit text overlay, it is pretty easy to create such images.

For example, the product image URL is:
https://ik.imagekit.io/ikmedia/hoodie_white.png

Now, we want to add a 15% OFF label with a solid color background.

The final URL becomes:

https://ik.imagekit.io/ikmedia/hoodie_white.png?tr=w-394,h-540,l-text,i-15% OFF,co-FFFFFF,bg-EF6823,r-4,pa-8_8,lx-10,ly-10,tg-bold,fs-30,l-end

You can use this URL in mobile, desktop, iOS, and Android applications, and the result will look the same.

Let's understand the different parts of this URL one by one:

  • w-394,h-540 is basically resizing image to 394x540 dimension.
  • l-text is for adding a text layer.
  • i-15% OFF is adding 15% OFF text on the image.
  • co-FFFFFF is setting the color of text overlay to white.
  • bg-EF6823 is setting background color to #EF6823.
  • r-4 is used to set the border-radius of the background to 4px.
  • pa-8_8 is for setting top-bottom and left-right padding to 8px.
  • lx and ly are used to control the position of text overlay layer relative to background image.
  • tg and fs are used to control the font typography and size.
  • l-end denotes the end of layer.

The resulting image:

Watermark images

Let's say the base image URL is - https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg

Overlay image logo URL is:
https://ik.imagekit.io/demo/logo-white_SJwqB4Nfe.png

Now to overlay this logo over the base image we will pass the path of overlay image i.e. logo-white_SJwqB4Nfe.png inside an image layer.

Final URL:
https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg?tr=l-image,i-logo-white_SJwqB4Nfe.png,l-end

You can also control the position, width, and other attributes of the overlay image, all using URL parameters. Learn more from the image overlay layer documentation.

To control the position of the overlay image layer relative to the background image, we can use lfo parameter. lfo parameter accepts relative position values i.e. top, right, bottom, left, etc.

Top position:

https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg?tr=l-image,i-logo-white_SJwqB4Nfe.png,lfo-top,l-end

You can use a combination of image watermarks and text overlays to create irresistible personalized banners for users.

Example 1:

https://ik.imagekit.io/ikmedia/accessories_banner.jpg?tr=w-1200,h-400:l-text,ff-PlayfairDisplay-Bold.ttf,i-HI JOHN,co-0450D5,fs-24,lx-850,ly-120,l-end:l-text,ff-PlayfairDisplay-Bold.ttf,i-EPIC FASHION,fs-36,lx-850,ly-158,l-end:l-text,ff-PlayfairDisplay-Bold.ttf,i-SALE,fs-104,lx-850,ly-190,l-end:l-text,ff-PlayfairDisplay-Bold.ttf,i-2 DAYS TO GO,fs-38,lx-850,ly-294,l-end

Example 2:

https://ik.imagekit.io/ikmedia/white-canvas.png?tr=w-1000,h-667:l-image,i-site_graphics/girl_in_white_500.jpg,w-500,h-667,lx-0,ly-0,l-end:l-image,i-site_graphics/guy_in_yellow_500.jpg,w-500,h-667,lx-500,ly-0,l-end:l-text,i-HI JOHN‚ HERE ARE SOME RECOMMENDED PRODUCTS FOR YOU,bg-FFFFFF80,pa-20,fs-30,co-000000,tg-b,r-16,lx-15,ly-550,l-end

Photo collage

You can combine multiple photos together and create a beautiful dynamic collage.

Example:
https://ik.imagekit.io/ikmedia/white-canvas.png?tr=w-1245,h-1245:l-image,i-women-dress-1.jpg,lx-0,ly-0,w-600,h-600,b-15_FFFFFF,l-end:l-image,i-women-dress-2.jpg,lx-615,ly-0,w-600,h-600,b-15_FFFFFF,l-end:l-image,i-women-dress-3.jpg,lx-0,ly-615,w-600,h-600,b-15_FFFFFF,l-end:l-image,i-women-dress-4.jpg,lx-615,ly-615,w-600,h-600,b-15_FFFFFF,l-end:l-text,i-Women's Clothing,bg-00000080,pa-20,fs-60,co-FFFFFF,l-end:b-2_000000

You can check out how to create a photo collage tutorial to learn more.

Summary

  • It is easy to create image and text overlay using native CSS. You can copy-paste the code from the above examples and start using them right away.
  • Although CSS is powerful, creating overlay effects using CSS has some limitations, e.g., the same code doesn't work for all devices, and if the user downloads the image, the overlay effect is lost.
  • Using an Image CDN like ImageKit.io simplifies the text and image overlay generation.
  • You can create a free account and start creating beautiful visuals dynamically using URL-parameters.
  • Setting up ImageKit only takes a few minutes. You can integrate your existing storage or any web server with a few clicks.