Home  >  Article  >  Web Front-end  >  How to make a right-angled trapezoid with css

How to make a right-angled trapezoid with css

WBOY
WBOYOriginal
2021-12-03 17:09:188134browse

In CSS, you can use the border attribute to make a right-angled trapezoid. The syntax is "element {border: 0px solid transparent; border-top: trapezoid height solid color; border-left: trapezoid length solid transparent}".

How to make a right-angled trapezoid with css

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to make a right-angled trapezoid in css

In css, you can first set the border size of the empty element to 0 and the color to transparent, and then Set the border size of one side to the height of the trapezoid, and set the border color to the color of the trapezoid.

You need to use the border attribute. The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div class=&#39;ti&#39;><div>
<style>
.ti {
    height:100px;
width:100px;
border:0px solid transparent;
border-top:60px solid #000;
        }
</style>
</body>
</html>

Output result:

How to make a right-angled trapezoid with css

Then give the border next to the color that has been set Just set the thickness value of a border. There is no need to set the color or the transparent color. The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div class=&#39;ti&#39;><div>
<style>
.ti {
    height:100px;
width:100px;
border:0px solid transparent;
border-top:60px solid #000;
border-left:50px solid transparent;
        }
</style>
</body>
</html>

Output result:

How to make a right-angled trapezoid with css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to make a right-angled trapezoid with css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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