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

Detailed explanation of this pointing problem in JavaScript

Preface The this pointer in JS has always been a ...

JavaScript manual implementation of instanceof method

1. Usage of instanceof instanceof operator is use...

Detailed explanation of MySql slow query analysis and opening slow query log

I have also been researching MySQL performance op...

Ubuntu 18.04 installs mysql 5.7.23

I installed MySQL smoothly in Ubuntu 16.04 before...

Vue+swiper realizes timeline effect

This article shares the specific code of vue+swip...

jQuery implements the function of adding and deleting employee information

This article shares the specific code of jQuery t...

MySQL 5.7.21 installation and configuration tutorial under Window10

This article records the installation and configu...

Instructions for using the --rm option of docker run

When the Docker container exits, the file system ...

A brief discussion on MySQL B-tree index and index optimization summary

MySQL's MyISAM and InnoDB engines both use B+...

How to create a flame effect using CSS

The main text starts below. 123WORDPRESS.COM Down...

Detailed introduction and usage examples of map tag parameters

Map tags must appear in pairs, i.e. <map> .....

A summary of the reasons why Mysql does not use date field index

Table of contents background explore Summarize ba...

A brief talk about Rx responsive programming

Table of contents 1. Observable 2. Higher-order f...

Practical method of deleting a row in a MySql table

First, you need to determine which fields or fiel...