{"id":3047,"date":"2017-03-06T18:20:58","date_gmt":"2017-03-07T00:20:58","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=2168"},"modified":"2017-03-06T18:20:58","modified_gmt":"2017-03-07T00:20:58","slug":"css-split-color-text-effect","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-split-color-text-effect\/","title":{"rendered":"CSS Snippets: Split Color Text Effect"},"content":{"rendered":"<p>Over here at CSS Newbie, we love using CSS to create unique text effects for our projects. Today, we&#8217;re going to use CSS to create a split-color text effect, where an angled line is drawn through a block of text, and the text is one color above the line, and another color below the line. It&#8217;s a really neat effect and a great way to add both color and dimension to your projects. To see how it works, check out the snippets below.<\/p>\n<p>First we&#8217;ll need some pretty straightforward HTML to define your text, which can say anything you like. Your HTML should look something like this:<\/p>\n<pre>&lt;div class=\"content\"&gt;\n\u00a0 \u00a0 &lt;h1 data-letters=\"pizza is life\"&gt;pizza is life&lt;\/h1&gt;\n&lt;\/div&gt;<\/pre>\n<p>All you need is a div and an h1 tag. Make sure you include an attribute (can be called whatever you like, as long as you remember to call\u00a0it as a variable later on in your CSS) whose value matches your text, in this case: pizza is life.<\/p>\n<p>Now it&#8217;s time for the css:<\/p>\n<pre>::-moz-selection {\n background: #5b63fe;\n}\n::selection {\n background: #5b63fe;\n}\nh1 {\n width: 100%;\n height: 100%;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n text-align: center;\n position: absolute;\n margin: 0;\n font-family: 'Helvetica', sans-serif;\n color: #ff4d7f;\n font-size: 50px;\n letter-spacing: -0.225rem;\n background: white;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n z-index: 1;\n -webkit-transition: font-size 250ms cubic-bezier(0.59, 0.04, 0.3, 1.43);\n transition: font-size 250ms cubic-bezier(0.59, 0.04, 0.3, 1.43);\n}\n@media screen and (min-width: 768px) {\n h1 {\n font-size: 80px;\n }\n}\n@media screen and (min-width: 1024px) {\n h1 {\n font-size: 100px;\n }\n}\nh1:after {\n content: attr(data-letters);\n position: absolute;\n left: 0;\n z-index: 2;\n overflow: hidden;\n white-space: wrap;\n width: 100%;\n height: 100%;\n top: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n text-align: center;\n position: absolute;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n color: #e3f7f0;\n background: #5b63fe;\n -webkit-clip-path: polygon(0 0, 100% 0, 100% 25%, 0 77%);\n clip-path: polygon(0 0, 100% 0, 100% 25%, 0 77%);\n}<\/pre>\n<p>So now, your code should look like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2169 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-07-at-11.25.45-AM-1024x282.png\" alt=\"Screen Shot 2017-03-07 at 11.25.45 AM\" width=\"599\" height=\"165\" \/><\/p>\n<p>Pretty cool, right? You&#8217;ll notice that the text above the blue line is a light minty green, while the text below the line is a bright fuchsia. We achieve this effect mostly using pseudo-selectors (:after) and the useful clip-path property. Try it out for yourself in your own projects &#8212; feel free to customize the colors, text, and font family.<\/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>Over here at CSS Newbie, we love using CSS to create unique text effects for our projects. Today, we&#8217;re going to use CSS to create a split-color text effect, where an angled line is drawn through a block of text, [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/css-split-color-text-effect\/\" title=\"Click to read 'CSS Snippets: Split Color Text Effect'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2847,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[174],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3047"}],"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=3047"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3047\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2847"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}