Skip to content

Instantly share code, notes, and snippets.

@BindiChen
Created February 25, 2020 18:46
Show Gist options
  • Save BindiChen/188d3a47f01562aac8e0c3dc7921e350 to your computer and use it in GitHub Desktop.
Save BindiChen/188d3a47f01562aac8e0c3dc7921e350 to your computer and use it in GitHub Desktop.
How does CSS triangle work?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How does CSS triangle work?</title>
<style>
.box_1 {
width: 50px;
height: 50px;
margin: 100px auto;
}
.box_1 {
border-top: 5px solid red;
border-right: 5px solid lime;
border-bottom: 5px solid blue;
border-left: 5px solid yellow;
}
.box_2 {
width: 50px;
height: 50px;
margin: 100px auto;
}
.box_2 {
border-top: 60px solid red;
border-right: 60px solid lime;
border-bottom: 60px solid blue;
border-left: 60px solid yellow;
}
.box_3 {
width: 0;
height: 0;
margin: 100px auto;
}
.box_3 {
border-top: 60px solid red;
border-right: 60px solid lime;
border-bottom: 60px solid blue;
border-left: 60px solid yellow;
}
.box_4 {
width: 0;
height: 0;
margin: 100px auto;
}
.box_4 {
border-top: 60px solid red;
border-right: 60px solid transparent;
border-bottom: 60px solid transparent;
border-left: 60px solid transparent;
}
.box_5 {
width: 0;
height: 0;
margin: 100px auto;
}
.box_5 {
border-top: 120px solid red;
border-right: 60px solid transparent;
border-bottom: 60px solid transparent;
border-left: 60px solid transparent;
}
</style>
</head>
<body>
<div class="box_1"></div>
<div class="box_2"></div>
<div class="box_3"></div>
<div class="box_4"></div>
<div class="box_5"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment