Home > Web Front-end > CSS Tutorial > How to Create a Transparent Triangle with a Black Border Using CSS?

How to Create a Transparent Triangle with a Black Border Using CSS?

Mary-Kate Olsen
Release: 2024-10-31 19:25:29
Original
376 people have browsed it

How to Create a Transparent Triangle with a Black Border Using CSS?

Creating a Transparent Triangle with a Border Using CSS

Question:

How can we create a transparent triangle with a black border using CSS, excluding SVG vectors?

Answer:

WebKit-Only Solution:

A WebKit-exclusive approach involves utilizing the ▲ character:


<pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false">
Copy after login
Copy after login

.triangle {
-webkit-text-stroke: 12px black;
color: transparent;
font-size: 200px;
}

<pre class="brush:php;toolbar:false">
Copy after login
Copy after login


<pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false">
Copy after login
Copy after login

<pre class="brush:php;toolbar:false">
Copy after login
Copy after login


This method creates a triangle shape using the WebKit-specific -webkit-text-stroke property, which outlines the text with a stroke of the specified color and thickness. The text itself is set to transparent, making the triangle effectively transparent.

The above is the detailed content of How to Create a Transparent Triangle with a Black Border Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template