CSS realizes the scene analysis of semi-transparent border and multiple border

CSS realizes the scene analysis of semi-transparent border and multiple border

Scenario 1:

To achieve a semi-transparent border:

Due to the default behavior of CSS styles, the background color is rendered in the range of content+padding+border.

The semi-transparent border is affected by the main color, and the effect achieved is

Solution:

Use the background-clip property to specify the background drawing area so that the drawing area is limited to content + padding.

Div {
border:10px solid rgba(0,0,0,.5);
background: lightblue;
background-clip: padding-box;
}

Supplement: background-clip is not compatible with IE6-8, Opera10

Scenario 2:

To implement multiple borders:

Solution 1: Use box-shadow to generate multiple projections

The code and effect are as follows:

div {
background:#c3e6f4;
box-shadow:0 0 0 15px #b7dae6,0 0 0 30px #cce2ea;
}

Solution 2: Box border combined with stroke attributes (outline)

Features: Only double borders can be achieved, more flexible, and can use dotted line and other effects

The code and effect are as follows:

div {
border: 6px dashed #c3f4ec;
outline: 10px solid #d9faf6;
background-clip: padding-box;
} 

Summarize

The above is the scenario analysis of implementing semi-transparent borders and multiple borders with CSS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  TypeScript problem with iterating over object properties

>>:  Summary of MySQL slow log related knowledge

Recommend

Talk about the understanding of CSS attribute margin

1.What is margin? Margin is used to control the sp...

jQuery combined with CSS to achieve the return to top function

CSS Operations CSS $("").css(name|pro|[...

Solution to leaving gaps between BootStrap grids

Table of contents [See an example]: [The original...

HTML table tag tutorial (44): table header tag

<br />In order to clearly distinguish the ta...

Install MySQL in Ubuntu 18.04 (Graphical Tutorial)

Tip: The following operations are all performed u...

Summary of Spring Boot Docker packaging tools

Table of contents Spring Boot Docker spring-boot-...

Awk command line or script that helps you sort text files (recommended)

Awk is a powerful tool that can perform some task...

Explore VMware ESXI CLI common commands

Table of contents 【Common commands】 [Summary of c...

Example of converting spark rdd to dataframe and writing it into mysql

Dataframe is a new API introduced in Spark 1.3.0,...

MySQL select results to perform update example tutorial

1. Single table query -> update UPDATE table_n...

Springboot+VUE to realize login and registration

This article example shares the specific code of ...

Html makes a simple and beautiful login page

Let’s take a look first. HTML source code: XML/HT...

Analysis of MySQL query sorting and query aggregation function usage

This article uses examples to illustrate the use ...

Detailed explanation of the method of comparing dates in MySQL

If there is a table product with a field add_time...