HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="wrap">
<h1 class="title-wrap rotate">
<span class="text-row large">Multiline Padded</span>
<span class="text-row text-row-2 large">Text Experiments</span>
</h1>
<h2>3 Methods</h2>
<ul>
<li>Nested spans</li>
<li>pseudo elements and parent</li>
<li>Box-decoration-break</li>
</ul>
<h2>Rules</h2>
<ul>
<li>Text should be highlighted, i.e. have a background colour
</li>
<li>Highlights should only cover areas where there is text</li>
<li>Each line should have a little left and right padding so that the text isn’t flush against the highlight box</li>
<li>Both lines must be able to be indented</li>
</ul>
<h2>Using nested spans</h2>
<article class="spans">
<h1>
<a href="#" role="link">
<span>Spring</span>
<span>
<span>@</span><span>Park</span>
</span>
</a>
</h1>
</article>
<article class="bg1">
<h1>
<a href="#" role="link">
<span>Spring</span>
<span>
<span>@</span><span>Park</span>
</span>
</a>
</h1>
</article>
<article class="bg2">
<h1>
<a href="#" role="link">
<span class="line-1 group">
<span class="l-1">Spring</span>
</span>
<span class="l-1 line-2">
<span>@</span><span>Park</span>
</span>
</a>
</h1>
</article>
<h2>Using a :before pseudo element</h2>
<ul>
<li>cross browser?? this and box-dec
also: keep in mind stacking context
also: box-sizing:border-box with negative margins???</li>
<li>How about with gradient bg's?</li>
</ul>
<span class="row">
<span class="imgbg">Span with :before bg</span>
<span class="imgbg imgbg2">Span with :before bg</span>
</span>
<p>This solution uses 3 elements, a parent element, and 2 child elements, one for each row of text.</p>
<p>Using an absolutely positioned :before element, sized to the same size as the parent, sent behind using negative z-index, then then given further padding using negative margin values creates this effect. This solution probably gives the most control and least css</p>
<p>The secret sauce really lies in the <strong><code>display: table</code></strong> property on the .text-row span. It stop the absolutely positioned :before element from taking up too much space.</p>
<p>The beauty of this solution is that the padding will always scale perfectly with the text (especially when using em values on the padding and negitive margin), also you can align rows as close as you want with line-height without the background ever clipping the text.</p>
<span class="row">
<span class="imgbg bg3">Spring</span>
<span class="imgbg imgbg2 bg3">@Park</span>
</span>
<p>However when we add a transform to tilt it we have problems with cutting off of the bottom of the text:</p>
<span class="row">
<span class="imgbg rotate">Span with :before bg</span>
<span class="imgbg imgbg2 rotate">Span with :before bg</span>
</span>
<p>This is because adding a transform creates a new stacking context, and the negative z-indexed pseudo elements rise to the top again.</p>
<p>But if we put the transform on the parent row instead it works great</p>
<p>With this setup we can now introduce some extra properties for styling flare, such as box-shadow and text-shadow.</p>
<article class="titling">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row">Spring</span>
<span class="text-row text-row-2 symbol"><span class="symbol">@</span>Park</span>
</a>
</h1>
<p>
<a href="#" role="link">
See Whats On
</a>
</p>
</article>
<h3>Limitations</h3>
<p>Due to there being a span for each line you have to manually set the text ie. what text is on what line. In this respect it's non-responsive.</p>
<p>You can't add a border around all the rows... you can add a box-shadow to all the text-rows at the right and bottom, but trying to add a box shadow on the top or right will look wierd visually.</p>
<article class="titling">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row">This is a longer line</span>
<span class="text-row text-row-2">Too short</span>
</a>
</h1>
</article>
<p>Can kinda visually break if you use the box-shadow and the second line isn't as long as the first... but that's probably an edge case seen as you can control the margin-left of the second line to push it across anyway.</p>
<p>Beware that things get wierd if the banner is smaller than it's container, make sure to appropriately size the text with media queries... if you've used em values for the padding and negative margin everything else should scale nicely based on the text-size.</p>
<h3>Some more examples using this technique</h3>
<article class="titling bubble">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row">Bubble</span>
<span class="text-row text-row-2">Stylin'</span>
</a>
</h1>
</article>
<article class="titling font">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row">Spring</span>
<span class="text-row text-row-2">Break!</span>
</a>
</h1>
</article>
<article class="titling skew">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row">Supreme</span>
<span class="text-row text-row-2">Athletic</span>
<span class="text-row text-row-2">Italics</span>
</a>
</h1>
</article>
<article class="titling skew border">
<h1 class="title-wrap rotate">
<a href="">
<span class="text-row block">Stagger</span>
<span class="text-row text-row-2 block">Titling</span>
<span class="text-row text-row-2 block">Blocks</span>
</a>
</h1>
</article>
<h2>Box-decoration</h2>
<article class="break">
<p>The element that contains the text string must be set to display: inline.</p>
<ul>
<li>If my element was inline-block, I’d get the desired effect right up until text spills onto a new line. At that point, subsequent lines would inherit the full width of the parent because of how inline-block works.</li>
<li>If my element was a block element, it would always assume the full width of the parent (unless explicitly declared, which is not an option), thus leading to the same behaviour above.</li>
</ul>
<h1>
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<p>This is the problem, if you want to adjust the line height so the text is more tightly set, the background clips the top and bottom of some text characters. Look at the lowercase g above.</p>
<h1 class="lh">
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<p>
You can see the other problem is that we need to add a padding on the text... but when set as inline block the text will only add left/right padding at the start and end of the text string, not the start and end of each line as rendered. Also, with this method any top/bottom padding will just increase the cropping / hiding of other lines of text.
</p>
<p>So, how can we solve this? Luckily, CSS has thrown us a piece of candy in the <strong><code>box-decoration-break</code></strong> property. Let’s take a look.</p>
<h2>The box-decoration-break: Property</h2>
<blockquote>The box-decoration-break CSS property specifies how the background, padding, border, border-image, box-shadow, margin and clip of an element is applied when the box for the element is fragmented. Fragmentation occurs when an inline box wraps onto multiple lines…</blockquote>
<p>Basically, this property is giving us a bit more granularity in how an inline element gets rendered.</p>
<p>By default, it’s set to <strong><code>box-decoration-break: slice</code></strong>, which means that it treats the inline box as if it weren’t fragmented at all. I like to think of it like this. </p>
<p>Imagine that we took that multi-line inline element, stretched it out onto one line, applied the styling, sliced it into pieces, then moved each piece back to a new line. The result would be that the properties mentioned above would act on the entire box of the element, rather than each of its parts.</p>
<p>However, there is a second option for us, and that is: <strong><code>box-decoration-break: clone</code></strong></p>
<p>When we set the property to clone, we can imagine a similar scenario as above, except one important thing. This time, let’s imagine that all the styles get applied after the element gets fragmented and distributed on multiple lines. In other words, paddings, borders, etc would be applied to each fragment almost as if they were separate elements.</p>
<h1 class="lh bdc">
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<h3>Limitations</h3>
<p>The h1 has to be inline, that means you can't offset the lines in any way. You can't use text-indent. Also you couldn't use text-align: justify; if you wanted to do that sort of thing.</p>
<p>You also can't use psuedo elements such as :first-letter or :first-line because The pseudo element only works if the parent element is a block container box.</p>
<p>The problem is still with line-height causing cropping on the text :(</p>
<p>Also any top padding you add will result in a row cropping text in the row above.</p>
<p>So really this solution has limited appeal.</p>
<h1 class="bdc lh2">
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<p>The advantages are that you can apply all these properties on one element, no need for a parent wrapper or new elements for each subsequent line of text. This solution is therefore also more responsive in that you can resize the container smaller and the line padding will still work as expected.</p>
<h3>Gradient backgrounds</h3>
<h1 class="bdc lh2 grad">
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<p>Fine when using a gradient from left to right</p>
<h1 class="bdc lh2 grad1">
Hello, this is a long line of text that spills onto multiple lines. Make it wrap.
</h1>
<p>But not top to bottom</p>
<h2>Box-shadow technique</h2>
<h1 class="box-shadow">
We can use box-shadow to add left and right padding to each line of our inline element.
</h1>
<p>...However that shifts the padding over to the left and unless you use a parent element around it you can't shift it over again using padding or margin, because it'll just add it to the first line otherwise.</p>
<p>We control the top and bottom padding with a mix of line-height and padding-top/bottom. unfortunately this is a balancing act, you still can't have tightly set lines and large top/bottom padding.</p>
<p>This technique works much better with uppercase text, that way there arent hanging ligatures to be cropped off</p>
<p>This is working in Chrome and Safari, and now working in Firefox 32+, in my quick tests. Chrome and Safari require it to be -webkit-box-decoration-break.</p>
</article>
<h2>Box-decoration-break</h2>
<h1 class="pre">We can use background: linear-gradient to our inline element to have it spread over all lines.</h1>
<p>With box-decoration-break:clone;</p>
<h1 class="pre break">We can use background: linear-gradient on our inline element and add box-decoration-break:clone; to have the entire gradient complete on each line</h1>
<h2>Background-attachment:fixed</h2>
<p>If we use the same technique as above but replace box-decoration-break:clone; with background-attachment:fixed we should see the same gradient being used across each line. </p>
<p><strong>NB: resize the viewport if below isnt visible.. think this is a codepen bug</strong></p>
<h1 class="pre-fixed">We can add background: linear-gradient to our inline element and add background-attachment:fixed to make it the same gradient on all lines.</h1>
<p>This technique has limited use as a solution in this context due to the following issues:</p>
<ul>
<li>Inability to add padding to the start / end of each line.</li>
<li>Browser support: currently broke in Firefox... It also sometimes requires a viewport resize in chrome (see below)</li>
<li>Quite glitchy in Chrome in respect that sometimes you need to resize the viewport to see the styling actually take effect (this requires further testing, it may just be a codepen bug i'm experiencing).</li>
</ul>
<h2>However...</h2>
<p>Making the element <code>display:block</code> seems to fix the glitchyness, but we now cover the entire area of the block with the gradient.</p>
<p>Downsides.... the title must be <code>display: inline</code> but that can probably be solved with a parent wrapper.</p>
<h1 class="pre-fixed-2">We can add background: linear-gradient to our BLOCK element and add background-attachment:fixed to make it the same gradient on all lines.</h1>
<h2>UPDATE 3/10/24 - The final boss solution</h2>
<p>Using Chris coyier <a href="https://codepen.io/tfoh/pen/YzmqQmr?editors=1100">Pre-wrap solution</a>, together with <code>box-decoration-break</code> for our horizontal paddings.</p>
<p>We fix lines of text having their decenders / bottom chopped off by adding them into a span and raising it's z-index above the box-decoration layer.</p>
<p>The heading text must be <code>display: inline;</code> for this to work, if you need a block level element this may require a further wrapper.</p>
<p>This solution requires an extra span inside but so do pretty much all other solutions for this.</p>
<p>Because the top and bottom paddings are created with a border, they are outisde of the elements "box" and will encroach towards other elements, rather than respecting vertical margins.</p>
<p>Can't use this technique to do gradient BGs due to the required border color.</p>
<h1 class="pre-wrap"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></h1>
<h1 class="pre-wrap"><span>Short.</span></h1>
<p>Can see the issue with having the heading as <code>display: inline;</code>above. 2 consecutive headings can appear on one line.</p>
<h2>2 nested spans:</h2>
<p>For this next example, we use 2 spans inside the heading instead, and that lets the heading remain as <code>display: block;</code>.</p>
<p>We can also now remove the top/bottom border and control that with top/bottom padding instead. It still breaks out the heading's content box, making it visually move further towards its sibling elements, but it's less CSS and reads better. We no longer need the pre-wrap property either.</p>
<h2 class="pre-wrap-heading"><span class="pre-wrap"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></span></h2>
<h2 class="pre-wrap-heading"><span class="pre-wrap"><span>Short</span></span></h2>
<p></p>
<p>We still have the issue with line lengths if we want to use a dropshadow</p>
<h2 class="pre-wrap-heading"><span class="pre-wrap shadow"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></span></h2>
<p>But we can fix that by making the shadow bigger</p>
<h2 class="pre-wrap-heading"><span class="pre-wrap shadow-long"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></span></h2>
<p></p>
<p></p>
<p>We can't add a border without it looking weird:<p>
<h2 class="pre-wrap-heading"><span class="pre-wrap border"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></span></h2>
<p>But we can add an outline</p>
<h2 class="pre-wrap-heading"><span class="pre-wrap outline"><span>Pellentesque habitant morbi tristique senectus <br>et netus et malesuada fames ac turpis egestas.</span></span></h2>
</div><!-- wrap end -->
@import url("https://fonts.googleapis.com/css?family=Roboto:400,400i,700");
@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");
* {box-sizing: border-box;}
body {
margin-bottom: 100px;
}
.wrap {
max-width: 500px;
margin: 0 auto;
}
h2,h3 {margin-top: 50px;}
h1 + ul {
margin-top: 50px;
}
.spans {
h1 {
transform: rotate(-2deg);
padding: 2px;
font-size: 2rem;
font-family: "Roboto Slab", Serif;
a {
text-decoration: none;
color: white;
font-size: 25px;
line-height: 1.2; // gives more space around text
display: inline-block;
> span {
display: block;
padding: 2px 5% 10px;
width: auto;
float: left;
clear: left;
background: #ef2b81;
font-weight: 600;
font-size: 35px;
// second line
&:last-of-type {
margin-left: 65px;
position: relative;
// text group
span {
// symbol
&:first-of-type {
position: absolute;
top: -6px;
}
// text
&:last-of-type {
margin-left: 35px;
float: none;
background: none;
}
}
}
}
}
}
}
.bg1 {
h1 {
transform: rotate(-2deg);
padding: 10px 5px 5px;
font-size: 2rem;
font-family: "Roboto Slab", Serif;
background: #ef2b81;
width: 90%;
margin-left: 2%;
a {
text-decoration: none;
color: white;
font-size: 25px;
line-height: 0.7; // gives more space around text
display: inline-block;
> span {
display: block;
padding: 2px 5% 10px;
width: auto;
float: left;
clear: left;
background: #ef2b81;
font-weight: 600;
font-size: 35px;
}
}
}
}
.bg2 {
h1 {
transform: rotate(-2deg);
padding: 2px;
font-size: 2rem;
font-family: "Roboto Slab", Serif;
a {
text-decoration: none;
color: white;
font-size: 25px;
line-height: 0.7; // gives more space around text
display: inline-block;
span.line-1 {
margin-left:0;
// background: #ef2b81;
// background-image: url("http://imgur.com/9LMwgN9.png");
background-size: 200px 200px;
background-repeat: repeat;
// padding: 5px 5% 0;
display: block;
}
span.l-1 {
display: block;
padding: 2px 5% 10px;
width: auto;
float: left;
clear: left;
background: #ef2b81;
font-weight: 600;
font-size: 35px;
// second line
&.line-2 {
margin-left: 65px;
position: relative;
// text group
span {
// symbol
&:first-of-type {
position: absolute;
top: -6px;
}
// text
&:last-of-type {
margin-left: 35px;
float: none;
background: none;
}
}
}
}
}
}
}
.group:after {
content: "";
display: table;
clear: both;
}
.imgbg {
// transform: rotate(-2deg);
color: white;
position: relative;
margin-left: 0;
font-size: 1rem;
font-family: "Roboto Slab", Serif;
font-weight: 600;
line-height: 0.9em;
vertical-align: text-top;
padding: 5px 10px 0;
// display: block;
display: table;
// height: 17px;
// width: 50px;
&:before {
content:'';
background: #ef2b81;
position:absolute;
margin: -3px 0 -10px;
top:0;
bottom:0;
left:0;
right: 0;
z-index:-1;
}
&.rotate {
transform: rotate(-2deg);
}
}
.imgbg2 {
margin-left: 70px;
}
.bg3 {
font-size: 2rem;
display: table;
}
.row {
display: inline-block;
&.rotate {
transform: rotate(-2deg);
}
}
// Condensed down to just required properties
/////////////////////////////////////////////
h1.title-wrap {
display: block; // can be inline-block tbf
box-sizing: border-box;
a {
text-decoration: none;
}
&.rotate {
transform: rotate(-2deg);
margin-left: 5px;
}
.text-row {
color: white;
// must be relative so can absolutely position the :before
position: relative;
margin-left: 0;
// vertical-align: text-top;
font-size: 2rem;
font-family: "Roboto Slab", Serif;
font-weight: 600;
// add some flare
text-shadow: 2px 2px #b22161;
// control line spacing
line-height: 0.7em;
// the initial text padding to build on top of
padding: 5px 10px 0;
// make sure the pseudo element background only covers this element
// this is the secret sauce!!
display:table;
&.large {
font-size: 2.9rem;
}
&.text-row-2 {
// indent the line
margin-left: 70px;
}
&.symbol {
// if you need to add space for an absolutely positioned element
padding-left: 40px;
}
&:before {
content:'';
background: #ef2b81;
// add some flare
box-shadow: 4px 5px #b22161;
// control the extra padding of the background
margin: -3px 0 -0.3em;
// make it same size as parent
position: absolute;
top:0;
bottom:0;
left:0;
right: 0;
// send it behind
z-index:-1;
}
// if you need to absolutely position a symbol
.symbol {
position: absolute;
top: 0px;
left: 8px;
}
}
}
.titling {
p {
margin: 30px;
position: relative;
text-transform: uppercase;
font-size: 16px;
font-family: "Roboto Slab", Serif;
font-weight: 600;
&:before {
position: absolute;
content:'';
background: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 193 71'%3E%3Cpolygon fill='%23EF2B81' points='0.104,58.735 2.854,13.235 119.854,0.235 191.854,18.485 180.604,61.735 92.604,70.985 '/%3E%3C/svg%3E") no-repeat;
height: 71px;
width: 193px;
top:-27px;
left:-35px;
// send it behind
z-index:-1;
}
a {
color: white;
text-decoration: none;
position: relative;
&:before {
position: absolute;
content:"";
background: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 10'%3E%3Cpolygon fill='%23fff' points='0,0 0,10 5,5 '/%3E%3C/svg%3E") no-repeat;
height: 14px;
width: 6px;
left: -15px;
top: 5px;
}
}
}
}
.titling.bubble {
.text-row {
color: #1565C0;
text-shadow: -1px -1px #E1F5FE;
text-shadow: none;
&:before {
border-radius:25px;
background: #BBDEFB;
box-shadow: 6px 5px #1565C0;
// control the extra padding of the background
margin: -0.4em -0.3em -0.6em;
}
}
}
.titling.font {
.title-wrap.rotate {
transform: rotate(-10deg);
transform: skewY(-10deg);
}
.text-row {
font-family: "Montserrat", Sans-Serif;
text-transform: uppercase;
text-shadow: 2px 2px #0D47A1;
&:before {
// background: #1976D2;
// add some flare
// box-shadow: 4px 5px #0D47A1;
// control the extra padding of the background
// margin: -10px -5px -0.5em;
}
}
}
.titling.skew {
margin-top: 70px;
&.border {
.text-row {
font-family: "Roboto Slab", Serif;
line-height: 0.9em;
}
}
.title-wrap.rotate {
transform: rotate(0deg);
transform: skewX(-10deg);
}
.text-row {
font-family: "Montserrat", Sans-Serif;
text-transform: uppercase;
color: #eae;
// text-shadow: 2px 2px #0D47A1, -1px -1px #fff;
text-shadow: 2px 2px #0D47A1;
&.block {
display: block;
}
&.text-row-2 {
&:last-of-type {
margin-left: 4.5em;
}
}
&:before {
background: #1976D2;
// add some flare
// box-shadow: 4px 5px #0D47A1;
box-shadow: none;
// control the extra padding of the background
margin: -10px -5px -0.5em;
}
}
}
.break {
h1 {
font-family: "Montserrat", Sans-Serif;
background: #325fa4;
color: #fff;
display: inline;
//line-height: 1em;
&.lh {
line-height:0.9em;
padding: 2px 25px;
border: 1px solid black;
}
&.lh2 {
line-height:1.5em;
}
&.bdc {
box-decoration-break:clone;
padding: 3px 10px;
}
&.box-shadow {
line-height: 1em;
padding: 0.03em 0px;
background: orange;
box-shadow: 20px 0 0 orange, -20px 0 0 orange;
text-transform: uppercase
}
&.grad {
background: linear-gradient(
to right,
red, #f06d06
);
}
&.grad1 {
background: linear-gradient(
red, #f06d06
);
}
}
}
.pre {
width: 400px;
font: bold 28px sans-serif;
letter-spacing:-1px;
color: #fff;
background: linear-gradient(to right, #085d9d 0%, #92d5ff 100%);
display: inline;
line-height: 1.6em;
padding: 7px 3px;
white-space: pre-wrap;
&.break {
// background-attachment: fixed;
box-decoration-break:clone;
font-size: 40px;
line-height: 1.4em;
}
}
.pre-fixed {
// width: 400px;
// text-align: right;
font-weight: bold;
font-size: 28px;
letter-spacing:-1px;
color: #fff;
background: linear-gradient(to right, #085d9d 0%, #92d5ff 100%);
display: inline;
line-height: 1.6em;
padding: 7px 3px;
white-space: pre-wrap;
background-attachment: fixed;
}
.pre-fixed-2 {
// width: 400px;
// text-align: right;
font-weight: bold;
font-size: 28px;
letter-spacing:-1px;
color: #fff;
background: linear-gradient(to right, #085d9d 0%, #92d5ff 100%);
display: block;
line-height: 1.6em;
padding: 7px 3px 7px 20px;
white-space: pre-wrap;
background-attachment: fixed;
}
/* 0.25em is roughly equal to one space character. */
$text-padding-horizontal: 0.5em;
$text-padding-vert: 0.3em;
$text-bg: #ef2b81;
.title,
.pre-wrap {
position: relative;
line-height: 1.2;
font-size: 2rem;
color: #fff;
display: inline;
box-decoration-break: clone;
background: $text-bg;
padding-left: $text-padding-horizontal;
padding-right: $text-padding-horizontal;
> span {
position: relative;
z-index: 1;
}
}
h1.pre-wrap {
white-space: pre-wrap;
padding-right: $text-padding-vert;
border: 0 solid $text-bg;
border-width: $text-padding-vert 0;
}
h2 {
.pre-wrap {
padding: $text-padding-vert $text-padding-horizontal;
// background: linear-gradient(to right, #085d9d 0%, #92d5ff 100%);
background: -webkit-linear-gradient(0deg, #8000ff 0%, #e001b2 90%);
background-attachment: fixed; // relative to viewport, not element
// background-attachment: local;
background-clip: padding-box;
// &:after {
// content: "";
// position: absolute;
// inset: 0;
// background-color: #333;
// }
}
.shadow {
box-shadow: 0.5rem 0.5rem 0 black;
}
.shadow-long {
box-shadow: 1.2rem 1.2rem 0 black;
}
.border {
border: 5px solid black;
}
.outline {
outline: 5px solid black;
}
&.pre-wrap-heading {
// Prevent box-decoration BG from appearing outside the elements content box
padding-right: $text-padding-horizontal;
padding-block: $text-padding-vert;
// Purely for layout
margin-bottom: 50px;
}
}
// With thanks to:
//https://callmenick.com/dev/multi-line-padded-text-css-box-decoration-break/
Also see: Tab Triggers