Example code for implementing transparent gradient effects with CSS

Example code for implementing transparent gradient effects with CSS

The title images on Zhihu Discovery columns are generally displayed as shown below. Obviously, it is achieved using gradients. The idea is very interesting, mainly to have two aspects of cognition:

This picture can actually be divided into two parts. The right side controls the graphics and gradient, and the left side is a solid color background that has nothing to do with the gradient.

Transparent is also a color, and can be set as a gradient

I'll post my own code below for reference only.

layout

<body>
    <div class="bg-gradient">
        <div class="pic"></div> 
    </div>
</body>

CSS Styles

<style>
        .bg-gradient {
            margin: 0 auto;
            background: rgb(244, 195, 77);
            position: relative;
            width: 600px;
            height: 350px;
        }

        .bg-gradient .pic{
            background-image: linear-gradient(to right, rgb(244, 195, 77), transparent), url("bg.jpg");
            background-position: center;
            background-blend-mode: normal;
            position: absolute;
            height: 100%;
            width: 250px;
            right: 0;
        }
</style>

The final effect is as follows

The above is my code, thanks for watching.

ps: If you want to write something in it and something goes wrong, I don’t think it’s a problem. Well, that’s your problem. Listen to me, you have to solve it on your own. (Explicit words)

<<:  How to use jsonp in vue

>>:  The neglected special effects of META tags (page transition effects)

Recommend

How to view and clean up Docker container logs (tested and effective)

1. Problem The docker container logs caused the h...

How to solve the slow speed of MySQL Like fuzzy query

Question: Although the index has been created, wh...

MySQL latest version 8.0.17 decompression version installation tutorial

Personally, I think the decompressed version is e...

MySQL series 15 MySQL common configuration and performance stress test

1. Common MySQL configuration All the following c...

How to use docker compose to build fastDFS file server

The previous article introduced a detailed exampl...

Solution to define the minimum height of span has no effect

The span tag is often used when making HTML web pa...

Example of how to configure multiple virtual hosts in nginx

It is very convenient to configure virtual host v...

This article helps you understand PReact10.5.13 source code

Table of contents render.js part create-context.j...

Summary of basic usage of $ symbol in Linux

Linux version: CentOS 7 [root@azfdbdfsdf230lqdg1b...

Lambda expression principles and examples

Lambda Expressions Lambda expressions, also known...

Linux disk sequential writing and random writing methods

1. Introduction ● Random writing will cause the h...

How to install Zookeeper service on Linux system

1. Create the /usr/local/services/zookeeper folde...