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.
Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.
Upgrade to PROIf 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.
Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.
Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:
Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.
This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.
Upgrade to PRO
<div id="app">
<f7-app :params="f7params" :theme-dark="darkMode">
<!-- Statusbar -->
<f7-statusbar></f7-statusbar>
<!-- Left Panel -->
<f7-panel left reveal>
<f7-view id="left-panel-view">
<f7-page>
<f7-navbar title="Left Panel"></f7-navbar>
<f7-block strong>
<p>Left panel content goes here</p>
</f7-block>
<f7-block-title>Load page in panel</f7-block-title>
<f7-list>
<f7-list-item link="/about/" title="About"></f7-list-item>
<f7-list-item link="/form/" title="Form"></f7-list-item>
<f7-list-item link="#" panel-close title="Toggle Dark Mode" @click="darkMode = !darkMode"
></f7-list-item>
</f7-list>
<f7-block-title>Load page in main view</f7-block-title>
<f7-list>
<f7-list-item link="/about/" title="About" view="#main-view" panel-close></f7-list-item>
<f7-list-item link="/form/" title="Form" view="#main-view" panel-close></f7-list-item>
</f7-list>
</f7-page>
</f7-view>
</f7-panel>
<!-- Right Panel -->
<f7-panel right cover>
<f7-view id="right-panel-view">
<f7-page>
<f7-navbar title="Right Panel" sliding></f7-navbar>
<f7-block>
<p>Right panel content goes here</p>
</f7-block>
<f7-block-title>Load page in panel</f7-block-title>
<f7-list>
<f7-list-item link="/about/" title="About"></f7-list-item>
<f7-list-item link="/form/" title="Form"></f7-list-item>
</f7-list>
<f7-block-title>Load page in main view</f7-block-title>
<f7-list>
<f7-list-item link="/about/" title="About" view="#main-view" panel-close></f7-list-item>
<f7-list-item link="/form/" title="Form" view="#main-view" panel-close></f7-list-item>
</f7-list>
</f7-page>
</f7-view>
</f7-panel>
<!-- Main View -->
<f7-view id="main-view" main class="safe-areas">
<f7-page>
<f7-navbar large title-large="My App">
<f7-nav-left>
<f7-link icon-if-ios="f7:menu" icon-if-md="material:menu" panel-open="left"></f7-link>
</f7-nav-left>
<f7-nav-title >My App</f7-nav-title>
<f7-nav-right>
<f7-link icon-if-ios="f7:menu" icon-if-md="material:menu" panel-open="right"></f7-link>
</f7-nav-right>
</f7-navbar>
<f7-toolbar bottom>
<f7-link>Left Link</f7-link>
<f7-link>Right Link</f7-link>
</f7-toolbar>
<f7-block strong>
<p>Here is your blank <f7-link href="https://framework7.io/" external target="_blank">Framework7</f7-link><a href=""></a> app. Let's see what we have here.</p>
</f7-block>
<f7-block-title>Navigation</f7-block-title>
<f7-list>
<f7-list-item link="/about/" title="About"></f7-list-item>
<f7-list-item link="/form/" title="Form"></f7-list-item>
</f7-list>
<f7-block-title>Expandable card</f7-block-title>
<f7-card expandable>
<f7-card-content :padding="false">
<div class="bg-color-yellow" :style="{height: '300px'}">
<f7-card-header text-color="black" class="display-block">
Framework7
<br/>
<small :style="{opacity: 0.7}">Build Mobile Apps</small>
</f7-card-header>
<f7-link card-close color="black" class="card-opened-fade-in" :style="{position: 'absolute', right: '15px', top: '15px'}" icon-f7="close_round_fill"></f7-link>
</div>
<div class="card-content-padding">
<p>Framework7 - is a free and open source HTML mobile framework to develop hybrid mobile apps or web apps with iOS or Android (Material) native look and feel...</p>
</div>
</f7-card-content>
</f7-card>
<f7-block-title>Modals</f7-block-title>
<f7-block strong>
<f7-row>
<f7-col width="50">
<f7-button fill raised popup-open="#popup">Popup</f7-button>
</f7-col>
<f7-col width="50">
<f7-button fill raised login-screen-open="#login-screen">Login Screen</f7-button>
</f7-col>
</f7-row>
</f7-block>
<f7-block-title>Panels</f7-block-title>
<f7-block strong>
<f7-row>
<f7-col width="50">
<f7-button fill raised panel-open="left">Left Panel</f7-button>
</f7-col>
<f7-col width="50">
<f7-button fill raised panel-open="right">Right Panel</f7-button>
</f7-col>
</f7-row>
</f7-block>
<f7-list>
<f7-list-item link="/dynamic-route/blog/45/post/125/?foo=bar#about" title="Dynamic Route"></f7-list-item>
<f7-list-item link="/load-something-that-doesnt-exist/" title="Default Route (404)"></f7-list-item>
</f7-list>
</f7-page>
</f7-view>
<!-- Popup -->
<f7-popup id="popup">
<f7-view>
<f7-page>
<f7-navbar title="Popup">
<f7-nav-right>
<f7-link popup-close>Close</f7-link>
</f7-nav-right>
</f7-navbar>
<f7-block>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque, architecto. Cupiditate laudantium rem nesciunt numquam, ipsam. Voluptates omnis, a inventore atque ratione aliquam. Omnis iusto nemo quos ullam obcaecati, quod.</f7-block>
</f7-page>
</f7-view>
</f7-popup>
<!-- Login Screen -->
<f7-login-screen id="login-screen">
<f7-view>
<f7-page login-screen>
<f7-login-screen-title>Login</f7-login-screen-title>
<f7-list form>
<f7-list-input label="Username" name="username" placeholder="Username" type="text"></f7-list-input>
<f7-list-input label="Password" name="password" type="password" placeholder="Password"></f7-list-input>
</f7-list>
<f7-list>
<f7-list-button title="Sign In" login-screen-close></f7-list-button>
<f7-block-footer>
<p>Click Sign In to close Login Screen</p>
</f7-block-footer>
</f7-list>
</f7-page>
</f7-view>
</f7-login-screen>
</f7-app>
</div>
<!-- About Page Template -->
<template id="page-about">
<f7-page>
<f7-navbar title="About" back-link="Back"></f7-navbar>
<f7-block-title>About My App</f7-block-title>
<f7-block strong>
<p>Here is About page!</p>
<p>You can go <f7-link back>back</f7-link>.</p>
<p>Mauris posuere sit amet metus id venenatis. Ut ante dolor, tempor nec commodo rutrum, varius at sem. Nullam ac nisi non neque ornare pretium. Nulla mauris mauris, consequat et elementum sit amet, egestas sed orci. In hac habitasse platea dictumst.</p>
<p>Fusce eros lectus, accumsan eget mi vel, iaculis tincidunt felis. Nulla tincidunt pharetra sagittis. Fusce in felis eros. Nulla sit amet aliquam lorem, et gravida ipsum. Mauris consectetur nisl non sollicitudin tristique. Praesent vitae metus ac quam rhoncus mattis vel et nisi. Aenean aliquet, felis quis dignissim iaculis, lectus quam tincidunt ligula, et venenatis turpis risus sed lorem. Morbi eu metus elit. Ut vel diam dolor.</p>
</f7-block>
</f7-page>
</template>
<!-- Form Page Template -->
<template id="page-form">
<f7-page>
<f7-navbar title="Form" back-link="Back"></f7-navbar>
<f7-block-title>Form Example</f7-block-title>
<f7-list form>
<f7-list-input
label="Name"
type="text"
placeholder="Name"
></f7-list-input>
<f7-list-input
label="E-mail"
type="email"
placeholder="E-mail"
></f7-list-input>
<f7-list-input
label="URL"
type="url"
placeholder="URL"
></f7-list-input>
<f7-list-input
label="Password"
type="password"
placeholder="Password"
></f7-list-input>
<f7-list-input
label="Phone"
type="tel"
placeholder="Phone"
></f7-list-input>
<f7-list-input
label="Gender"
type="select"
>
<option selected>Male</option>
<option>Female</option>
</f7-list-item>
<f7-list-input
label="Birth date"
type="date"
placeholder="Birth date" value="2014-04-30"
></f7-list-input>
<f7-list-item title="Toggle">
<f7-toggle slot="after"></f7-toggle>
</f7-list-item>
<f7-list-input
label="Slider"
:input="false"
>
<f7-range slot="input" min="0" max="100" value="50" step="1" :label="true"></f7-range>
</f7-list-input>
<f7-list-input
label="Textarea"
type="textarea"
placeholder="Bio"
></f7-list-input>
<f7-list-input
label="Resizable"
type="textarea"
placeholder="Bio"
resizable
></f7-list-input>
</f7-list>
<f7-block-title>Checkbox group</f7-block-title>
<f7-list form>
<f7-list-item v-for="n in 3" :key="n" checkbox name="my-checkbox" :value="n" :title="'Checkbox ' + n"></f7-list-item>
</f7-list>
<f7-block-title>Radio buttons group</f7-block-title>
<f7-list form>
<f7-list-item v-for="n in 3" :key="n" radio name="my-radio" :checked="n === 1" :value="n" :title="'Radio ' + n"></f7-list-item>
</f7-list>
<f7-block-title>Buttons</f7-block-title>
<f7-block strong>
<f7-row tag="p">
<f7-button class="col">Button</f7-button>
<f7-button class="col" fill>Fill</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" raised>Raised</f7-button>
<f7-button class="col" raised fill>Raised Fill</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" round>Round</f7-button>
<f7-button class="col" round fill>Round Fill</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" outline>Outline</f7-button>
<f7-button class="col" round outline>Outline Round</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" small outline>Small</f7-button>
<f7-button class="col" small round outline>Small Round</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" small fill>Small</f7-button>
<f7-button class="col" small round fill>Small Round</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" large raised>Large</f7-button>
<f7-button class="col" large fill raised>Large Fill</f7-button>
</f7-row>
<f7-row tag="p">
<f7-button class="col" large fill raised color="red">Large Red</f7-button>
<f7-button class="col" large fill raised color="green">Large Green</f7-button>
</f7-row>
</f7-block>
</f7-page>
</template>
<!-- Dynamic Routing Page Template -->
<template id="page-dynamic-routing">
<f7-page>
<f7-navbar title="Dynamic Route" back-link="Back"></f7-navbar>
<f7-block strong>
<ul>
<li><b>Url:</b> {{$f7route.url}}</li>
<li><b>Path:</b> {{$f7route.path}}</li>
<li><b>Hash:</b> {{$f7route.hash}}</li>
<li><b>Params:</b>
<ul>
<li v-for="(value, key) in $f7route.params" :key="key"><b>{{key}}:</b> {{value}}</li>
</ul>
</li>
<li><b>Query:</b>
<ul>
<li v-for="(value, key) in $f7route.query" :key="key"><b>{{key}}:</b> {{value}}</li>
</ul>
</li>
<li><b>Route:</b> {{$f7route.route}}</li>
</ul>
</f7-block>
<f7-block strong>
<f7-link @click="$f7router.back()">Go back via Router API</f7-link>
</f7-block>
</f7-page>
</template>
<!-- Page Not Found Template -->
<template id="page-not-found">
<f7-page>
<f7-navbar title="Not found" back-link="Back"></f7-navbar>
<f7-block strong>
<p>Sorry</p>
<p>Requested content not found.</p>
</f7-block>
</f7-page>
</template>
// Init F7 Vue Plugin
Framework7.use(Framework7Vue);
// Init Page Components
Vue.component('page-about', {
template: '#page-about'
});
Vue.component('page-form', {
template: '#page-form'
});
Vue.component('page-dynamic-routing', {
template: '#page-dynamic-routing'
});
Vue.component('page-not-found', {
template: '#page-not-found'
});
// Init App
new Vue({
el: '#app',
data: function () {
return {
darkMode: false,
// Framework7 parameters here
f7params: {
// Enable panel left visibility breakpoint
panel: {
leftBreakpoint: 960
},
root: '#app', // App root element
id: 'io.framework7.testapp', // App bundle ID
name: 'Framework7', // App name
theme: 'auto', // Automatic theme detection
view: {
pushState: true,
history: true,
},
// App routes
routes: [
{
path: '/about/',
component: 'page-about',
options: {
// options
animate: true,
pushState: true,
history: true,
},
},
{
path: '/form/',
component: 'page-form'
},
{
path: '/dynamic-route/blog/:blogId/post/:postId/',
component: 'page-dynamic-routing'
},
{
path: '(.*)',
component: 'page-not-found',
},
],
}
}
},
});
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
if ($$('#popup').hasClass( "modal-in" ))
{ myApp.closePanel();
return false;
}
else {
mainView.router.back();
}
return true;
}
Also see: Tab Triggers