Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKristian Woods
23,414 PointsWhat is the best way to go about creating shaped divs in CSS?
I'm trying to create a div that has a point at the bottom, but the method I'm trying doesn't seem to work.
Can someone recommend an article, perhaps?
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title></title>
</head>
<body>
<div id="second-div"></div>
</body>
</html>
#second-div{
width: 100%;
height: 400px;
background-color: orange;
position: relative;
}
#second-div::after {
position: absolute;
width: 50%;
height: 100px;
content: "";
bottom: -63px ;
left: 0;
background-color: #fff;
-webkit-transform: skewY(10deg);
transform: skewY(10deg);
border: 3px solid red;
}
#second-div::before {
position: absolute;
width: 50%;
height: 100px;
content: "";
bottom: -63px ;
right: 0;
background-color: #fff;
-webkit-transform: skewY(-10deg);
transform: skewY(-10deg);
border: 3px solid green;
}
1 Answer
Steven Parker
231,264 PointsProbably the easiest and most versatile way to create shapes is with the "clip-path" (clipping path) property. There are several online tools that actually write the code for you by just drawing what you want. Here's a couple of them:
Clayton Batchelor
181 PointsClayton Batchelor
181 PointsHere is an article I found on Stack Overflow that may help you.
<a href="https://stackoverflow.com/questions/19719048/center-triangle-at-bottom-of-div?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa">Stack Overflow</a>