{"id":2237,"date":"2017-04-02T22:05:59","date_gmt":"2017-04-02T22:05:59","guid":{"rendered":"http:\/\/cssreset.com\/?p=2237"},"modified":"2017-04-02T22:05:59","modified_gmt":"2017-04-02T22:05:59","slug":"css-basics-how-to-make-shapes-part-ii","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-basics-how-to-make-shapes-part-ii\/","title":{"rendered":"CSS Basics: How to Make Shapes, Part II"},"content":{"rendered":"<p>(if you haven&#8217;t already, make sure that you read <a href=\"https:\/\/cssdeck.com\/blog\/\/css-basics-how-to-make-shapes-part-i\/\" target=\"_blank\">Part I<\/a> first!)<\/p>\n<p>We&#8217;ve already covered how to create some basic shapes using CSS (circle, square, triangle, etc), but now it&#8217;s time to make shapes that are just a little more complex.<\/p>\n<p>Let&#8217;s start with the five-pointed star. Like with all the other shapes we created in part one, we&#8217;re going to start with an empty div. For this example, we&#8217;ve simply given the div the class &#8220;star.&#8221; Your HTML should look like this:<\/p>\n<pre>&lt;div class=\"star\"&gt;&lt;\/div&gt;<\/pre>\n<p>And your CSS should be as follows:<\/p>\n<pre>.star {\r\n margin: 100px 0;\r\n position: relative;\r\n display: block;\r\n color: red;\r\n width: 0px;\r\n height: 0px;\r\n border-right: 100px solid transparent;\r\n border-bottom: 70px solid #ffc100;\r\n border-left: 100px solid transparent;\r\n -moz-transform: rotate(35deg);\r\n -webkit-transform: rotate(35deg);\r\n -ms-transform: rotate(35deg);\r\n -o-transform: rotate(35deg);\r\n}\r\n.star:before {\r\n border-bottom: 80px solid #ffc100;\r\n border-left: 30px solid transparent;\r\n border-right: 30px solid transparent;\r\n position: absolute;\r\n height: 0;\r\n width: 0;\r\n top: -45px;\r\n left: -65px;\r\n display: block;\r\n content: '';\r\n -webkit-transform: rotate(-35deg);\r\n -moz-transform: rotate(-35deg);\r\n -ms-transform: rotate(-35deg);\r\n -o-transform: rotate(-35deg);<\/pre>\n<pre>}\r\n.star:after {\r\n position: absolute;\r\n display: block;\r\n color: red;\r\n top: 3px;\r\n left: -105px;\r\n width: 0px;\r\n height: 0px;\r\n border-right: 100px solid transparent;\r\n border-bottom: 70px solid #ffc100;\r\n border-left: 100px solid transparent;\r\n -webkit-transform: rotate(-70deg);\r\n -moz-transform: rotate(-70deg);\r\n -ms-transform: rotate(-70deg);\r\n -o-transform: rotate(-70deg);\r\n content: '';\r\n}<\/pre>\n<p>Your final product should look like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-2238 aligncenter\" alt=\"Screen Shot 2017-02-17 at 1.41.35 PM\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.41.35-PM.png\" width=\"420\" height=\"400\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.41.35-PM.png 420w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.41.35-PM-300x285.png 300w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.41.35-PM-180x171.png 180w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/p>\n<p>To make things a little more complicated, next let&#8217;s make an octagon. Let&#8217;s give the octagon a class of &#8220;stop-sign,&#8221; because most stop signs are octagons.<\/p>\n<p>&lt;div class&#8221;stop-sign&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>Your CSS should look like this:<\/p>\n<pre>.stop-sign {\r\n width: 100px;\r\n height: 100px;\r\n background: #ff4040;\r\n position: relative;\r\n}\r\n.stop-sign:before {\r\n content: \"\";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n border-bottom: 29px solid #ff4040;\r\n border-left: 29px solid #fff;\r\n border-right: 29px solid #fff;\r\n width: 42px;\r\n height: 0;\r\n}\r\n.stop-sign:after {\r\n content: \"\";\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n border-top: 29px solid #ff4040;\r\n border-left: 29px solid #fff;\r\n border-right: 29px solid #fff;\r\n width: 42px;\r\n height: 0;\r\n}<\/pre>\n<p>You might notice that we don&#8217;t use transparent color for the border-left and border-rights like we have when making previous shapes. If we use transparent here instead of a color, the negative space that creates the octagon shape won&#8217;t appear, and your shape will just look like a red square. If you want the octagon to blend in with the rest of your page, then make sure that the border-left and border-right colors match the background color of your page.<\/p>\n<p>Your hexagon should look like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-2239 aligncenter\" alt=\"Screen Shot 2017-02-17 at 1.46.19 PM\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.46.19-PM.png\" width=\"220\" height=\"222\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.46.19-PM.png 220w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.46.19-PM-150x150.png 150w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.46.19-PM-180x181.png 180w\" sizes=\"(max-width: 220px) 100vw, 220px\" \/><\/p>\n<p>The last shape we&#8217;ll make is a cartoon-inspired chat bubble. The class for this shape is going to be &#8220;chat.&#8221;<\/p>\n<pre>&lt;div class=\"chat\"&gt;&lt;\/div&gt;<\/pre>\n<p>Your CSS should look like this:<\/p>\n<pre>.chat {\r\n width: 120px;\r\n height: 80px;\r\n background: #B0DFEC;\r\n position: relative;\r\n -moz-border-radius: 10px;\r\n -webkit-border-radius: 10px;\r\n border-radius: 10px;\r\n}\r\n.chat:before {\r\n content:\"\";\r\n position: absolute;\r\n right: 100%;\r\n top: 26px;\r\n width: 0;\r\n height: 0;\r\n border-top: 13px solid transparent;\r\n border-right: 26px solid #B0DFEC;\r\n border-bottom: 13px solid transparent;\r\n}<\/pre>\n<p>Which will render you a shape that looks like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-full wp-image-2240\" alt=\"Screen Shot 2017-02-17 at 1.55.31 PM\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.55.31-PM.png\" width=\"344\" height=\"200\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.55.31-PM.png 344w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.55.31-PM-300x174.png 300w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-17-at-1.55.31-PM-180x104.png 180w\" sizes=\"(max-width: 344px) 100vw, 344px\" \/><\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>(if you haven&#8217;t already, make sure that you read Part I first!)<\/p>\n<p>We&#8217;ve already covered how to create some basic shapes using CSS (circle, square, triangle, etc), but now it&#8217;s time to make shapes that are just a little more complex.<\/p>\n<p>Let&#8217;s [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/css-basics-how-to-make-shapes-part-ii\/\" title=\"Click to read 'CSS Basics: How to Make Shapes, Part II'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,36,42],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2237"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=2237"}],"version-history":[{"count":2,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2237\/revisions"}],"predecessor-version":[{"id":2347,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2237\/revisions\/2347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2240"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=2237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=2237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=2237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}