{"id":8256,"date":"2015-01-29T11:17:02","date_gmt":"2015-01-29T17:17:02","guid":{"rendered":"https:\/\/getflywheel.com\/?p=8256"},"modified":"2024-01-02T02:02:16","modified_gmt":"2024-01-02T08:02:16","slug":"create-shapes-css3","status":"publish","type":"resource","link":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/","title":{"rendered":"How to Create Shapes with CSS3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">What can you create with CSS shapes? After all, you can add a variety of basic shapes to your CSS style sheet by simply by using a bit of CSS3 coding. Why not see how you can use them on your site?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CSS shapes add interest to web pages. With browsers becoming increasingly more compatible, they can cut down on large, unnecessary images taking up space on your website. Changing colors and adjusting shapes could not be easier: Adjust a little CSS and watch your design take shape.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Shapes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s go over some simple shapes to start out. These are all fairly easy to use, but will still add some great visual interest to your site. The CSS is ready for you\u2014just copy and modify to fit your needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Squares<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/square.jpg\" alt=\"square\" class=\"wp-image-8266\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Squares are arguably the easiest shape to make in CSS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.square {\nwidth: 100px;\nheight: 100px;\nbackground: gray;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019d like a rectangle instead, simply adjust the width and height for either a horizontal or vertical rectangle.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Circle<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/circle.jpg\" alt=\"circle\" class=\"wp-image-8263\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A circle class can be a refreshing alternative to the usual square and rectangle images we\u2019re so used to seeing across the internet. Here&#8217;s the CSS for a circle: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.circle {\nwidth: 100px;\nheight: 100px;\nbackground: red;\n-webkit-border-radius: 50%;\n-moz-border-radius: 50%;\n-o-border-radius: 50%;\nborder-radius: 50%;\n}\n&#91;\/c<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer, the border radius can also be half of the width and height measurement. For example, because the width and height are 100px, we could also list the border-radius as 50px.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Triangle<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/triangle-up.jpg\" alt=\"triangle-up\" class=\"wp-image-8269\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s not forget about our three-sided friend. The triangle differs from the square and circle in that we need to include border declarations for left, right, and bottom. Notice that the width and height are set to 0. The borders are doing all the work here. The left and right are transparent while the bottom is set to 100px.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.triangle-up {\nwidth: 0;\nheight: 0;\nborder-left: 50px solid transparent;\nborder-right: 50px solid transparent;\nborder-bottom: 100px solid gray;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s compare a triangle that points up to one that points down. Most properties and values are the same in the two triangle examples. The one exception is the top border. We didn\u2019t need a top border for the <code>.triangle-up<\/code> class, and for the <code>.triangle-down<\/code> class we don\u2019t need a bottom border.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/triangle-down.jpg\" alt=\"triangle-down\" class=\"wp-image-8268\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>.triangle-down {\nwidth: 0;\nheight: 0;\nborder-top: 100px solid gray;\nborder-left: 60px solid transparent;\nborder-right: 60px solid transparent;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Complex Shapes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we\u2019ve covered the basics, let\u2019s try working on some more complex shapes, like rhomboids, stars, and speech bubbles.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Rhomboid<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/rhomboid.jpg\" alt=\"rhomboid\" class=\"wp-image-8264\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You may have to think back to Geometry 101, but a rhomboid is simply a parallelogram whose adjacent sides are unequal and whose angles aren\u2019t right angles. In other words, a skewed rectangle.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>20deg<\/code> refers to the tilt around the x-axis (the horizontal, if Geometry 101 is too far away). A margin-left of 25 is specified to allow for breathing room. If the shape is too far left, there is potential for it to be cut off. This ensures that the entire shape is included.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.rhomboid {\nwidth: 250px;\nheight: 150px;\nbackground-color: gray;\n-webkit-transform: skew(20deg);\n-moz-transform: skew(20deg);\n-o-transform: skew(20deg);\ntransform: skew(20deg);\nmargin-left: 25px;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Star<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/star.jpg\" alt=\"star\" class=\"wp-image-8267\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Creating a star is the perfect way to illustrate your rockstar CSS skills! Keep in mind our triangle from earlier in this post. A star is essentially putting three of those triangles together. We&#8217;re illustrating this with three different colors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Looking at the code below, the <code>.star-five<\/code> class is purple, which is the left part of the star. The rotation is what puts this into place. The <code>:before<\/code> pseudo-element is what gives the star the red piece on top. The <code>:after<\/code> pseudo-element is the green portion of the star. It\u2019s set to perfectly complete the shape.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.star-five {\nmargin: 50px 0;\nposition: relative;\ndisplay: block;\ncolor: purple;\nwidth: 0px;\nheight: 0px;\nborder-right: 100px solid transparent;\nborder-bottom: 70px solid purple;\nborder-left: 100px solid transparent;\n-moz-transform: rotate(35deg);\n-webkit-transform: rotate(35deg);\n-ms-transform: rotate(35deg);\n-o-transform: rotate(35deg);\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.star-five:before {\nborder-bottom: 80px solid red;\nborder-left: 30px solid transparent;\nborder-right: 30px solid transparent;\nposition: absolute;\nheight: 0;\nwidth: 0;\ntop: -45px;\nleft: -65px;\ndisplay: block;\n-webkit-transform: rotate(-35deg);\n-moz-transform: rotate(-35deg);\n-ms-transform: rotate(-35deg);\n-o-transform: rotate(-35deg);\ncontent: '';\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.star-five:after {\nposition: absolute;\ndisplay: block;\ncolor: green;\ntop: 3px;\nleft: -105px;\nwidth: 0px;\nheight: 0px;\nborder-right: 100px solid transparent;\nborder-bottom: 70px solid green;\nborder-left: 100px solid transparent;\n-webkit-transform: rotate(-70deg);\n-moz-transform: rotate(-70deg);\n-ms-transform: rotate(-70deg);\n-o-transform: rotate(-70deg);\ncontent: '';\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Speech Bubbles<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/01\/speech-bubble.jpg\" alt=\"speech-bubble\" class=\"wp-image-8265\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Want to add some dialog to your project? Sometimes a classic speech bubble is just what you need. Once again, the magic happens with the pseudo element.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.speech-bubble {\nwidth: 120px;\nheight: 80px;\nbackground: gray;\nposition: relative;\n-moz-border-radius: 10px;\n-webkit-border-radius: 10px;\nborder-radius: 10px;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.speech-bubble:before {\nposition: absolute;\nright: 100%;\ntop: 26px;\nwidth: 0;\nheight: 0;\nborder-top: 13px solid transparent;\nborder-right: 26px solid gray;\nborder-bottom: 13px solid transparent;\ncontent: '';\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">From squares to speech bubbles, CSS3 is making it possible to create all sorts of shapes in the browser. Once you learn the basics, you can use these concepts to create your own unique shapes. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure your project shapes up well, make sure you&#8217;re using the best possible <a href=\"https:\/\/wpengine.com\/wordpress-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress hosting<\/a> as the foundation for your site! Check out <a href=\"https:\/\/wpengine.com\/plans\/\" target=\"_blank\" rel=\"noreferrer noopener\">our plans<\/a> to learn more. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>What can you create with CSS shapes? After all, you can add a variety of basic shapes to your CSS style sheet by simply by using a bit of CSS3 coding. Why not see how you can use them on your site? CSS shapes add interest to web pages. With browsers becoming increasingly more compatible,<span class=\"tile__ellipses\">&hellip;<\/span><span class=\"tile__ellipses--animated\"><\/span><\/p>\n","protected":false},"author":1,"featured_media":141079,"template":"","resource-topic":[1396],"resource-role":[1397],"resource-type":[916],"class_list":["post-8256","resource","type-resource","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create shapes with CSS3<\/title>\n<meta name=\"description\" content=\"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create shapes with CSS3\" \/>\n<meta property=\"og:description\" content=\"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Engine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpengine\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-02T08:02:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/01\/Code-screen_1200x627.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"627\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/01\/Code-screen_1200x627.png\" \/>\n<meta name=\"twitter:site\" content=\"@wpengine\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/\",\"url\":\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/\",\"name\":\"How to create shapes with CSS3\",\"isPartOf\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\"},\"datePublished\":\"2015-01-29T17:17:02+00:00\",\"dateModified\":\"2024-01-02T08:02:16+00:00\",\"description\":\"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.\",\"breadcrumb\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wpengine.com\/case-studies\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\/\/wpengine.com\/case-studies\/resources\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Create Shapes with CSS3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\",\"url\":\"https:\/\/wpengine.com\/case-studies\/\",\"name\":\"WP Engine\",\"description\":\"Managed Hosting for WordPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085\",\"name\":\"WP Engine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"caption\":\"WP Engine\"},\"sameAs\":[\"https:\/\/wpengine.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create shapes with CSS3","description":"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"How to create shapes with CSS3","og_description":"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.","og_url":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/","og_site_name":"WP Engine","article_publisher":"https:\/\/www.facebook.com\/wpengine","article_modified_time":"2024-01-02T08:02:16+00:00","og_image":[{"width":1200,"height":627,"url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/01\/Code-screen_1200x627.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/01\/Code-screen_1200x627.png","twitter_site":"@wpengine","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/","url":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/","name":"How to create shapes with CSS3","isPartOf":{"@id":"https:\/\/wpengine.com\/case-studies\/#website"},"datePublished":"2015-01-29T17:17:02+00:00","dateModified":"2024-01-02T08:02:16+00:00","description":"CSS shapes add interest to WordPress web pages. Learn how to adjust a little CSS and watch your design take shape.","breadcrumb":{"@id":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/case-studies\/resources\/create-shapes-css3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/case-studies\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/wpengine.com\/case-studies\/resources\/"},{"@type":"ListItem","position":3,"name":"How to Create Shapes with CSS3"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/case-studies\/#website","url":"https:\/\/wpengine.com\/case-studies\/","name":"WP Engine","description":"Managed Hosting for WordPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085","name":"WP Engine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","caption":"WP Engine"},"sameAs":["https:\/\/wpengine.com"]}]}},"acf":[],"grid_image_url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/01\/Code-screen_343x245.png","media-type":{"term_id":916,"name":"Article","slug":"article"},"role":"<strong>Roles:<\/strong> Designer","topic":"<strong>Topics:<\/strong> Design","_links":{"self":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource\/8256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource"}],"about":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/types\/resource"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media\/141079"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media?parent=8256"}],"wp:term":[{"taxonomy":"resource-topic","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-topic?post=8256"},{"taxonomy":"resource-role","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-role?post=8256"},{"taxonomy":"resource-type","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-type?post=8256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}