CSS transparent border background-clip magic

CSS transparent border background-clip magic

This article mainly introduces the wonderful use of CSS transparent border background-clip, share it with everyone, and leave a note for yourself

<div class="border"></div>
.border {  
  width: 300px;  
  height: 300px;  
  background: url("https://waiqin.oss-cn-shenzhen.aliyuncs.com/jxb-vip-ts/activitys/activitys15677540269589timg.jpg");  
  background-size: cover;  
  margin-left: 100px;  
  border: 10px solid rgba(255,255,255,.6);  
  background-clip: padding-box;  
}

background-clip: padding-box; key code

The initial value of the background-clip property is border-box, which means that the background will be clipped by the element's border box (the outer edge of the border). If we don't want the background to invade the border, all we have to do is set its value to padding-box, so that the browser will use the outer edge of the inner margin to cut off the background.

Effect

Without background-clip: padding-box;, we can see that the background image is visible through the semi-transparent border.

After adding it, the background is cut off at the border.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Development details of Vue3 components

>>:  DHTML objects (common properties of various HTML objects)

Recommend

HTML input file control limits the type of uploaded files

Add an input file HTML control to the web page: &...

Solve the problem that Docker cannot ping the host machine under Mac

Solution Abandon the Linux virtual machine that c...

How to use environment variables in nginx configuration file

Preface Nginx is an HTTP server designed for perf...

Specific usage of CSS compound selectors

Intersection Selector The intersection selector i...

Detailed explanation of Linx awk introductory tutorial

Awk is an application for processing text files, ...

Tips for List Building for Website Maintenance Pages

And, many times, maintenance requires your website...

One sql statement completes MySQL deduplication and keeps one

A few days ago, when I was working on a requireme...

How to install Odoo12 development environment on Windows 10

Preface Since many friends say they don’t have Ma...

Good website copywriting and good user experience

Looking at a website is actually like evaluating a...

Linux system dual network card binding configuration implementation

System version [root@ ~]# cat /etc/redhat-release...

Docker removes abnormal container operations

This rookie encountered such a problem when he ju...

Detailed explanation of the usage of two types of temporary tables in MySQL

External temporary tables A temporary table creat...

Example code for css3 to achieve scroll bar beautification effect

The specific code is as follows: /*Scroll bar wid...

A brief discussion on the differences between FTP, FTPS and SFTP

Table of contents Introduction to FTP, FTPS and S...