{"id":3038,"date":"2017-02-13T18:27:28","date_gmt":"2017-02-14T00:27:28","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=2105"},"modified":"2017-02-13T18:27:28","modified_gmt":"2017-02-14T00:27:28","slug":"css-shapes-how-to-make-a-heart","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-shapes-how-to-make-a-heart\/","title":{"rendered":"CSS Shapes: How to Make a Heart"},"content":{"rendered":"<p>With Valentine&#8217;s Day season upon us, you might find yourself wanting to add some seasonal flair to your websites or projects. An easy way to do this is by adding heart shapes to your pages. You can do this by using a heart graphic or by using CSS to style a div element to look like a heart. Creating a heart shape out of a div takes more than a few lines of code, but it&#8217;s not terribly complicated. Take a look at the snippet below to see how you can do it for your own projects:<\/p>\n<p><a href=\"https:\/\/www.facebook.com\/photo.php?fbid=3543872870595&amp;set=a.3543872670590.1073741834.1085670865&amp;type=3&amp;theater&amp;notif_t=photo_comment&amp;notif_id=1486934646612746\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-2106 aligncenter\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-14-at-11.22.31-AM.png\" alt=\"Screen Shot 2017-02-14 at 11.22.31 AM\" width=\"208\" height=\"180\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Here&#8217;s what your HTML should look like:<\/p>\n<pre>&lt;div id=\"heart\"&gt;&lt;\/div&gt;<\/pre>\n<p>And your CSS:<\/p>\n<pre>#heart {\n position: relative;\n width: 100px;\n height: 90px;\n}\n\n#heart:before,\n#heart:after {\n position: absolute;\n content: \"\";\n left: 50px;\n top: 0;\n width: 50px;\n height: 80px;\n background: #f054ad;\n -moz-border-radius: 50px 50px 0 0;\n border-radius: 50px 50px 0 0;\n -webkit-transform: rotate(-45deg);\n -moz-transform: rotate(-45deg);\n -ms-transform: rotate(-45deg);\n -o-transform: rotate(-45deg);\n transform: rotate(-45deg);\n -webkit-transform-origin: 0 100%;\n -moz-transform-origin: 0 100%;\n -ms-transform-origin: 0 100%;\n -o-transform-origin: 0 100%;\n transform-origin: 0 100%;\n}\n\n#heart:after {\n left: 0;\n -webkit-transform: rotate(45deg);\n -moz-transform: rotate(45deg);\n -ms-transform: rotate(45deg);\n -o-transform: rotate(45deg);\n transform: rotate(45deg);\n -webkit-transform-origin: 100% 100%;\n -moz-transform-origin: 100% 100%;\n -ms-transform-origin: 100% 100%;\n -o-transform-origin: 100% 100%;\n transform-origin :100% 100%;\n}<\/pre>\n<p>As you can see, the shape is built primarily using the :before and :after pseudo-selectors, which is how the symmetrical curved shapes are formed. Have fun experimenting with this code and adjusting the color and size to your liking.<\/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>With Valentine&#8217;s Day season upon us, you might find yourself wanting to add some seasonal flair to your websites or projects. An easy way to do this is by adding heart shapes to your pages. You can do this by [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/css-shapes-how-to-make-a-heart\/\" title=\"Click to read 'CSS Shapes: How to Make a Heart'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2816,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3038"}],"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=3038"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3038\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2816"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}