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 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.
<html>
<body>
<center>
<h1>SVG 3D seamless weaving pattern</h1>
<svg xmlns='http://www.w3.org/2000/svg' width="720px" height="480px">
<title>SVG 3D weaving pattern</title>
<desc>Different seamless SVG pattern 3D weaving pattern - 3D Webmuster in variations of grey</desc>>
<defs>
<pattern id="svg3Dpattern" width="120" height="80" patternUnits="userSpaceOnUse" patternTransform="rotate(0) scale(1)">
<path d="M30,80L60,60L60,0L60,80" class="patterntop"/>
<path d="M60,60L90,80L60,80L60,60" class="patternright"/>
<path d="M0,0C0,0 27.068,18.046 44.843,29.895C54.021,36.014 65.979,36.014 75.157,29.895C92.932,18.046 120,0 120,0L120,20C120,20 92.402,38.399 74.64,50.24C65.775,56.15 54.225,56.15 45.36,50.24C27.598,38.399 0,20 0,20L0,0" class="patternleft"/>
<path d="M14.987,70.008L14.988,70.008L45,50L45.36,50.24C54.225,56.15 65.775,56.15 74.64,50.24L75,50L105.012,70.008L105.013,70.008C109.563,72.992 114.781,74.485 120,74.485L120,80L90,80L60,60L30,80L0,80L0,74.485C5.219,74.485 10.437,72.992 14.987,70.008Z" class="patternleft"/>
<path d="M60,80L45,80L45,70L0,40L0,20L45.36,50.24C49.793,53.195 54.896,54.673 60,54.673L60,80Z" class="patternright"/>
<path d="M74.966,50.022L120,20L120,40L75,70L75,80L60,80L60,54.673C65.104,54.673 70.207,53.195 74.64,50.24L74.966,50.022Z" class="patterntop"/>
<path d="M0,14.673L0,0L30,0L14.966,10.022L14.64,10.24C10.207,13.195 5.104,14.673 0,14.673Z" class="patternleft"/>
<path d="M120,14.673C114.896,14.673 109.793,13.195 105.36,10.24L90,0L120,0L120,14.673Z" class="patternleft"/>
<path d="M120,74.485C114.777,74.485 109.553,72.99 105.001,70L105,70L105,30L60,0L90.003,0.002L105.36,10.24C109.793,13.195 114.896,14.673 120,14.673L120,74.485Z" class="patternright"/>
<path d="M14.999,70C10.447,72.99 5.223,74.485 0,74.485L0,14.673C5.104,14.673 10.207,13.195 14.64,10.24L14.966,10.022L29.966,0.023L60,0L15,30L15,70L14.999,70Z" class="patterntop"/>
<path d="M60,34.485C54.776,34.485 49.552,32.989 45,29.999L45,0L60,0L60,34.485Z" style="fill:rgb(51,51,51);"/>
<path d="M60,34.485L60,0L75,0L75,29.999C70.448,32.989 65.224,34.485 60,34.485Z" class="patterntop"/>
</pattern>
</defs>
<rect x="0" y="0" width="720px" height="480px" fill="url(#svg3Dpattern)" stroke="" stroke-width="">
<!-- <animate id="animation1" attributeName="opacity" from="0.3" to="1" dur="5s" begin="0s;animation2.end" />
<animate id="animation2" attributeName="opacity" from="1" to="0.3" dur="2s" begin="animation1.end+3s" /> -->
</rect>
<rect id="bglabel" x="240" y="360" rx="15" ry="15" width="240px" height="100px" fill="#Fff" fill-opacity="0.8" stroke="" stroke-width=""/>
<text class="mylabel" x="260" y="400">Rotation: <tspan id="inlineRotation">0°</tspan></text>
<text class="mylabel" x="260" y="440">Scale: <tspan id="inlineScale">1x</tspan></text>
<!-- <rect id="refRect" x="120" y="80" width="120" height="80" fill="url(#svg3Dpattern)" stroke="none"/> -->
</svg>
<div id="controller">
<h2>Playing with scale and rotate on the pattern</h2>
<label style="text-align:left;">Rotation in degree: <span id="lblRotation">0°</span></label>
<input id="myRotation" type="range" min="0" max="360" step="1" value="0" onchange="fChangeAngle()" oninput="fChangeAngle()"/>
<label style="text-align:left;">Scale factor: <span id="lblScale">1x</span></label>
<input id="myScale" type="range" min="1" max="3" step="0.05" value="1" onchange="fChangeAngle()" oninput="fChangeAngle()"/>
</div>
</center>
</body>
</html>
body{
background-color:#FC3;
padding:0px;
margin:0px;
font-family: Raleway, sans-serif;
}
h1{
font-weight: 200;
}
h2{
font-weight: 500;
}
.patterntop{
fill:rgb(102,102,102);
}
.patternleft{
fill:rgb(153,153,153);
}
.patternright{
fill:rgb(51,51,51);
}
#controller{
width: 680px;
height: 180px;
margin: 10px;
padding: 20px;
border: 2px solid grey;
font-weight: 400;
}
label{
text-align: left;
}
#myRotation, #myScale{
width: 100%;
}
#lblRotation, #lblScale{
color: darkgreen;
font-weight: 500;
}
.mylabel{
fill: darkgreen;
font-family: Raleway;
font-weight: 200;
font-size: 2em;
}
#inlineRotation, #inlineScale{
font-weight: 400;
}
function fChangeAngle() {
//reference slider values
var angle = document.getElementById('myRotation').value;
var scale = document.getElementById('myScale').value;
//create string as value for the patternTransform attribute
var myvalsp = "rotate("+ angle +") scale("+ scale +")";
//modify patternTransform attribute with rotate and scale function
document.getElementById("svg3Dpattern").setAttribute("patternTransform", myvalsp);
//refresh label with current rotation angle and scale factor
document.getElementById("lblRotation").innerHTML = angle+"°";
document.getElementById("inlineRotation").innerHTML = angle+"°";
document.getElementById("lblScale").innerHTML = scale+"x";
document.getElementById("inlineScale").innerHTML = scale+"x";
};
Also see: Tab Triggers