


When you think of using CSS to set the transparency of elements, your first reaction is to use the Opacity attribute to set transparency. In fact, there are other ways to set transparency in CSS. This chapter will introduce you to using the transparent attribute to set transparency, and using the transparent attribute to draw various triangles. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
So, do you ask what the css transparent attribute is and what it is used for?
In fact, css transparent is a shorthand for fully transparent black (black), that is, a value like rgba(0,0,0,0); it is used to specify a fully transparent color.
For example:
We define in css: background:transparent, which means setting the background to be transparent.
However, in fact, the default color of the background is a transparent attribute, so it is the same whether it is written or not. So why do we sometimes need to set the background to transparent? In what scenarios is transparent generally used:
If an element covers another element and you want to display the following element, then you need to set the background of the above element to transparent
Use of the transparent attribute under different css versions:
In css1, transparent is used as a parameter value of background-color to indicate that the background is transparent.
In css2, border-color also begins to accept transparent as a parameter value. "Open eBook(tm) Publication Structure 1.0.1" [OEB101] extends to color and also accepts transparent as a parameter value.
In CSS3, transparent is extended to any attribute with a color value.
Let’s take a lookCompatibility:
#1: border-color does not accept this value;
#2: color does not accept this value;
transparent property draws various triangles (used with the border property)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> * { margin: 0; padding: 0; } .demo { margin: 40px auto; width:800px; /*background-color: #f0ac6b;*/ } .demo *{ float: left; margin: 20px 30px; width: 0px; height: 0px; } .t1 { /*background-color: #f0ac6b;*/ border-bottom: 40px solid red; border-right: 20px solid transparent; border-left: 20px solid transparent; } .t2 { /*background-color: #f0ac6b;*/ border-bottom: 40px solid transparent; border-right: 40px solid red; /*border-left: 20px solid transparent;*/ } .t3 { border-top: 40px solid red; border-right: 20px solid transparent; border-left: 20px solid transparent; } .t4 { border-top: 40px solid transparent; border-left: 40px solid red; } .t5 { border-top: 40px solid red; border-right: 40px solid transparent; } .t6 { border-left: 40px solid transparent; border-bottom: 40px solid red; } .t7 { border-left: 40px solid red; border-bottom: 20px solid transparent; border-top: 20px solid transparent; } .t8 { border-right: 40px solid red; border-bottom: 20px solid transparent; border-top: 20px solid transparent; } </style> </head> <body> <div class="demo"> <div class="t1"></div> <div class="t3"></div> <div class="t2"></div> <div class="t4"></div> <div class="t5"></div> <div class="t6"></div> <div class="t7"></div> <div class="t8"></div> </div> </body> </html>
Rendering:
Summary: The above is an introduction to the transparent attribute and an example of using the transparent attribute. The example is very simple, you can try it.
The above is the detailed content of How to set transparency using the transparent property in css? The transparent property draws various triangles (code example). For more information, please follow other related articles on the PHP Chinese website!

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

CSSCountersareusedtomanageautomaticnumberinginwebdesigns.1)Theycanbeusedfortablesofcontents,listitems,andcustomnumbering.2)Advancedusesincludenestednumberingsystems.3)Challengesincludebrowsercompatibilityandperformanceissues.4)Creativeusesinvolvecust

Using scroll shadows, especially for mobile devices, is a subtle bit of UX that Chris has covered before. Geoff covered a newer approach that uses the animation-timeline property. Here’s yet another way.

Let’s run through a quick refresher. Image maps date all the way back to HTML 3.2, where, first, server-side maps and then client-side maps defined clickable regions over an image using map and area elements.

The State of Devs survey is now open to participation, and unlike previous surveys it covers everything except code: career, workplace, but also health, hobbies, and more.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
