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="container mx-auto my-12">
<div class="leading-normal w-3/4 mx-auto">
<h1 class="text-5xl font-light text-center mb-4">TA-Foodtrucks Example</h1>
<h2 class="text-xl font-light text-center">
TA-Foodtrucks uses the Craftplaces Api demo data to show the next food truck and street food dates in your area. You can customize the endpoints to get all dates for a specific vendor, for a specific city or just for a location you are interested in.
</h2>
</div>
<div class="ta-foodtrucks rounded-lg border-2 border-gray-200 shadow-xl px-4 py-4 mb-8" x-data="taFoodtrucks()" x-init="init()" x-cloak data-endpoint="https://api.craftplaces.com/api/v1/dip/location/twodays" data-locale="de-DE" data-min-height="10rem" data-duration="1000" data-today="Heute" data-tomorrow="Morgen" data-seperator=" - " data-suffix=" Uhr">
<div class="absolute flex items-center justify-center inset-0 w-full h-full text-gray-400 z-5" x-show="!initialized">
<svg xmlns="http://www.w3.org/2000/svg" class="fill-current h-24 w-24" viewBox="0 0 100 100">
<path d="M27.136 52.495c1.377 12.625 12.734 21.747 25.359 20.37s21.747-12.735 20.37-25.36m-3.878.423c1.14 10.438-6.378 19.91-16.915 21.06s-19.92-6.478-21.06-16.916">
<animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="1s" from="0 50 50" to="360 50 50" repeatCount="indefinite" />
</path>
</svg>
</div>
<div class="absolute flex-center inset-0 w-full h-full z-5" x-show="initialized && empty">
Sorry, no dates available at the moment...
</div>
<template x-for="(item, index) in dates" :key="item.id" x-if="initialized && !empty">
<div class="grid gap-4 grid-col-1 sm:grid-cols-4 items-center py-8">
<div class="relative rounded-full w-32 h-32 overflow-hidden bg-white border-2 border-solid border-gray-400 mx-auto">
<img :src="item.logo.url.local" alt="asdas" class="absolute inset-0 h-full w-full object-cover" />
</div>
<div class="sm:col-span-3 leading-tight">
<h4 class="text-md text-blue-600 font-bold border-b-2 border-dashed border-cool-gray-300 -ml-2 pl-2 pb-2 mb-1">
<span x-text="getWeekday(index, true)"></span>,
<span x-text="getDay(index)"></span>
</h4>
<h3 class="text-5xl font-light -ml-1">
<span x-text="getTime(index, ' - ', 'Uhr')"></span>
</h3>
<p class="text-base font-light mb-2">
<span x-text="item.name"></span>
: <span x-text="item.location.address.street"></span>
<span x-text="item.location.address.number"></span>,
<span x-text="item.location.address.city"></span>
</p>
<p class="text-base font-light mb-4">
<span class="font-normal" x-text="item.vendor.name.long"></span>:
<span x-text="item.vendor.offer"></span>
</p>
<div class="w-full flex flex-wrap justify-between font-normal text-sm">
<div class="flex flex-wrap items-center my-2">
<a :href="getWhat3WordsLink(index)" class="inline-flex text-sm text-pink-800 font-bold items-center" target="_blank">
<svg class="fill-current h-4" viewBox="0 0 576 512">
<path d="M288 0c-69.59 0-126 56.41-126 126 0 56.26 82.35 158.8 113.9 196.02 6.39 7.54 17.82 7.54 24.2 0C331.65 284.8 414 182.26 414 126 414 56.41 357.59 0 288 0zm0 168c-23.2 0-42-18.8-42-42s18.8-42 42-42 42 18.8 42 42-18.8 42-42 42zM20.12 215.95A32.006 32.006 0 0 0 0 245.66v250.32c0 11.32 11.43 19.06 21.94 14.86L160 448V214.92c-8.84-15.98-16.07-31.54-21.25-46.42L20.12 215.95zM288 359.67c-14.07 0-27.38-6.18-36.51-16.96-19.66-23.2-40.57-49.62-59.49-76.72v182l192 64V266c-18.92 27.09-39.82 53.52-59.49 76.72-9.13 10.77-22.44 16.95-36.51 16.95zm266.06-198.51L416 224v288l139.88-55.95A31.996 31.996 0 0 0 576 426.34V176.02c0-11.32-11.43-19.06-21.94-14.86z" />
</svg>
<span class="ml-1"> What3Words </span></a>
<span class="ml-2"> (<span x-text="item.location.position.what3words"></span>) </span>
</div>
<a :href="getGoogleMapsLink(index)" class="inline-flex text-sm text-pink-800 font-bold items-center my-2" target="_blank">
<svg class="fill-current h-4" viewBox="0 0 384 512">
<path d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z" />
</svg>
<span class="ml-1"> Google Maps </span>
</a>
</div>
</div>
</div>
</template>
</div>
<div class="leading-normal w-3/4 mx-auto">
<p class="text-xl font-bold text-center my-4">Links: <a href="https://github.com/markusantonwolf/ta-foodtrucks" class="text-pink-800 underline hover:text-black" target="_blank">GitHub Repo</a>, <a href="https://ta-gallery.markusantonwolf.com/city/" class="text-pink-800 underline font-bold hover:text-black" target="_blank">Demo</a>, <a href="https://ta-gallery.markusantonwolf.com/" class="text-pink-800 underline font-bold hover:text-black" target="_blank">Doku</a> and <a href="https://www.markusantonwolf.com/" class="text-pink-800 underline font-bold hover:text-black" target="_blank">Author</a></p>
</div>
</div>
.font-sans {
font-family: Raleway, Helvetica, Arial, sans-serif !important;
}
.min-h-64 {
min-height: 16rem !important;
}
[x-cloak] {
display: none !important;
}
Also see: Tab Triggers