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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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="tree">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1260 709" >
<defs>
<mask id="msk1">
<rect width="100%" height="100%" fill="black" />
<path fill="white" transform="scale(0.85) translate(0 170)" fill="none" stroke="white" fill-opacity="0.8" stroke-width="2" stroke-dasharray="1540" stroke-dashoffset="1540" d="M 375 425 Q 450 300 375 300 L 200 300 A 50 50 0 1 1 200 125 L 600 125 A 50 50 0 1 1 600 300 Q 475 300 375 425 Z" >
</mask>
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="4" dy="8" stdDeviation="4"/>
</filter>
</defs>
<image id="img1" xlink:href="https://i.stack.imgur.com/JWPjk.jpg" width="100%" height="100%" opacity="1" />
<image id="SnowMaiden" transform="translate(750 310)" xlink:href="https://i.stack.imgur.com/MAz5g.png"
width="60%" height="60%" opacity="0" >
<!-- Анимация появления снегурочки -->
<animate id="Maiden"
attributeName="opacity"
values="0;1"
begin="btn.click"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
<!-- Анимация движения снегурочки -->
<animateTransform id="RunMaiden"
attributeName="transform"
type="translate"
values="750 310; 300 310"
begin="Maiden.end-1.2s"
dur="2s"
fill="freeze"
restart="whenNotActive" />
<!-- Анимация движения снегурочки после стихов мальчика -->
<animateTransform id="RunMaiden2"
attributeName="transform"
type="translate"
values="300 310; 100 310"
begin="an_fill_none.end"
dur="2s"
fill="freeze"
restart="whenNotActive" />
</image>
<g id="MaidenWords">
<!-- Контур для слов снегурочки -->
<path transform="scale(0.6) translate(450 400)" filter="url(#shadow)" fill="none" stroke="white" fill-opacity="0.8" stroke-width="2" stroke-dasharray="1549" stroke-dashoffset="1549" d="M 375 425 Q 450 300 375 300 L 200 300 A 50 50 0 1 1 200 125 L 600 125 A 50 50 0 1 1 600 300 Q 475 300 375 425 Z" >
<!-- анимация прорисовки контура слов снегурочки -->
<animate id="Maiden_str"
attributeName="stroke-dashoffset"
values="1549;0"
begin="RunMaiden.end+0.5s"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
<!-- анимация заполнения фона контура -->
<animate id="Maiden_fill"
attributeName="fill"
values="transparent;white"
begin="Maiden_str.end"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
</path>
<text id="txt1" transform="translate(400 400 )" style="font-size:24px;fill:#0D440D;font-family:Garamond; opacity:0;"
x="0"
y="0">
<tspan x="-10" y="-50">Дети.Кто хочет подарков?</tspan>
<tspan x="-10" y="0">Читайте стихи про ёлочку! </tspan>
</text>
<!-- Анимация появления текста снегурочки -->
<animate id="text_opacity"
xlink:href="#txt1"
attributeName="opacity"
values="0;1"
dur="1s"
begin="Maiden_fill.end"
fill="freeze"
restart="whenNotActive" />
<!-- Исчезновение текста снегурочки -->
<animate id="disWordMaiden"
xlink:href="#MaidenWords"
attributeName="opacity"
values="1;0"
dur="1s"
begin="text_opacity.end+2s"
fill="freeze"
restart="whenNotActive" />
</g>
<!-- Анимация появления картинки мальчика, читающего стихи под ёлочкой на табуретке -->
<g transform="scale(0.6) translate(-320 470)">
<image id="img2" xlink:href="https://i.stack.imgur.com/MChyh.png" width="100%" height="100%" opacity="0" filter="url(#shadow)" >
<animate id="an_img"
attributeName="opacity"
values="0;1"
begin="disWordMaiden.end+1s"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
</image>
</g>
<!-- Контур для стихов мальчика -->
<path transform="scale(0.6) translate(0 200)" filter="url(#shadow)" fill="none" stroke="white" fill-opacity="0.8" stroke-width="2" stroke-dasharray="1549" stroke-dashoffset="1549" d="M 375 425 Q 450 300 375 300 L 200 300 A 50 50 0 1 1 200 125 L 600 125 A 50 50 0 1 1 600 300 Q 475 300 375 425 Z" >
<!-- анимация прорисовки контура для стихов -->
<animate id="an_str"
attributeName="stroke-dashoffset"
values="1549;0"
begin="an_img.end+0.5s"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
<!-- анимация заполнения фона контура -->
<animate id="an_fill"
attributeName="fill"
values="transparent;white"
begin="an_str.end"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
<!-- анимация исчезновения контура-->
<animate id="an_str_none"
attributeName="stroke-dashoffset"
values="0;1549"
begin="an_fill_none.end"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
<!-- анимация исчезновения фона контура -->
<animate id="an_fill_none"
attributeName="fill"
values="white;transparent"
begin="an_text.end"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
</path>
<g id="btn" filter="url(#shadow)">
<rect x="0" y="10" rx="15" stroke="green" id="rec1" width="100px" height="40px" fill="greenyellow" />
<text x="18" y="40" font-size="32" fill="crimson"> Start </text>
</g>
<!-- Блок стихов -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
width="30%" height="40%" viewBox="0 40 -200 100">
<text transform="translate(100 175 )" style="font-size:24px;fill:#0D440D;font-family:Garamond;
filter:"url(#shadow);"
x="0"
y="0">
<tspan x="0" y="0">Нарядная, пушистая</tspan>
<tspan x="0" y="100">К нам ёлочка пришла</tspan>
<tspan x="0" y="150">И аромат душистый</tspan>
<tspan x="0" y="200">Домой к нам принесла!</tspan>
<tspan x="0" y="250">Вокруг неё, зелёной,</tspan>
<tspan x="0" y="300">Мы водим хоровод,</tspan>
<tspan x="0" y="350">Сегодня встретим новый,</tspan>
<tspan x="0" y="400">Счастливый самый год!</tspan>
<!-- Анимация движения строчек стихов -->
<animateMotion id="an_text"
path="M 0 0 L 0 -400"
begin="an_fill.end+0.5s"
dur="8s"
repeatCount="1"
fill="freeze"
restart="whenNotActive" />
</text>
</svg>
<!-- Корзина с подарками -->
<image id="img4" transform="translate(370 480)" xlink:href="https://i.stack.imgur.com/F4BVa.png" width="30%" height="30%" opacity="0" filter="url(#shadow)" >
<animate id="Basket_Op"
attributeName="opacity"
values="0;1"
dur="0.1s"
begin="RunMaiden2.end"
fill="freeze"
restart="whenNotActive" />
<!-- Анимация Корзины с подарками к мальчику -->
<animateTransform id="Basket_Up" attributeName="transform" type="translate" values="370 480; 70 480" dur="2s" begin="Basket_Op.end" fill="freeze" />
<!-- Анимация исчезновения снегурочки -->
<animate id="No_Maiden"
attributeName="opacity"
xlink:href="#SnowMaiden"
values="1;0"
begin="Basket_Up.end-1s"
dur="2s"
repeatCount="1"
fill="freeze"
restart="whenNotActive"/>
</image>
</svg>
</div>
.tree {
width:100%;
height:100%;
outline:1px solid green;
position:relative;
}
.txt1 {
position:absolute;
top:25%;
left:5%;
}
Also see: Tab Triggers