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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
</head>
<body>
<div class="wrapper">
<div class="wrapper1">
<div>默认行为</div>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia dolore exercitationem, numquam esse aspernatur blanditiis excepturi mollitia expedita sit a perspiciatis. Facere mollitia recusandae minus numquam. Fugit nisi perspiciatis minus odio ea at nulla consectetur sequi eveniet rem iure expedita quam aspernatur officia in saepe facere deserunt et, illo impedit nemo quaerat labore earum! Aut molestias itaque quae molestiae quis nihil, consectetur ipsam. Qui dignissimos hic natus delectus doloremque repellat ratione possimus! Totam, consectetur dicta culpa reiciendis veniam cumque. Officia tempore perspiciatis explicabo corrupti placeat dolor ut voluptas earum qui quas voluptate ea commodi quibusdam sint nulla, itaque suscipit dolore quos? Laudantium consequatur aperiam voluptatibus accusantium commodi fuga! Quia, nemo nihil illum assumenda libero alias hic obcaecati reiciendis? Dolore adipisci eum, debitis ratione veniam ex magni culpa corporis deleniti libero ut officia, quas amet doloremque delectus blanditiis perferendis, aut id at. Veniam maxime nulla, minima ut unde totam obcaecati aliquid? Facilis sequi iusto, voluptate consectetur eum ipsum alias vitae tenetur eligendi praesentium earum beatae est quisquam dignissimos iste temporibus dolores. Alias officiis nobis adipisci quam possimus quos enim rem, cumque quidem deleniti corrupti eum eaque similique animi ex sequi, nemo nam beatae recusandae asperiores corporis atque? Ea ad praesentium sit?
</p>
</div>
<div class="wrapper2">
<div>阻止左滑返回</div>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Aliquid, dolore impedit praesentium aperiam quasi neque blanditiis, eligendi, recusandae quisquam reiciendis repellendus nulla obcaecati exercitationem architecto sed omnis fugit molestiae voluptate repudiandae aspernatur! Maiores officiis deleniti error nostrum fugiat veritatis cum voluptatem ullam et, ipsa autem facere accusamus corporis non. Repellendus hic facilis a eligendi tempore, perferendis fugiat provident tenetur nostrum ullam voluptatum obcaecati vel dignissimos alias voluptas blanditiis quia dolorem beatae odio, ea placeat optio culpa? Distinctio obcaecati quo dicta quis, porro, voluptatem provident modi laudantium asperiores dolorum soluta ea eaque hic autem cum deleniti maiores quaerat! Repellendus, eos esse quod odit eligendi sed vel soluta nulla temporibus molestiae obcaecati voluptas? Blanditiis, ipsum. Cupiditate cum ipsum voluptates. Temporibus nemo aspernatur maxime soluta. Iusto quam dolorem aperiam in facere hic. Possimus vero quos tenetur perferendis ad quod inventore. Quas dicta quos maiores est maxime, dignissimos aliquid officiis hic, fugit laudantium nesciunt officia. Eligendi expedita architecto doloremque a natus perferendis iure rem dolor aperiam possimus cum repellat modi adipisci nostrum non, iste maxime porro eos at mollitia, vel autem? Ut id, culpa eveniet deleniti minima veritatis reiciendis at odio soluta, iure ab esse autem voluptatum itaque cumque mollitia ratione. Nulla, perferendis odit.</p>
</div>
</div>
</body>
</html>
.wrapper {
display: flex;
gap: 20px;
}
.wrapper1,
.wrapper2 {
width: 300px;
height: 300px;
overflow: auto;
}
.wrapper1 {
border: 2px solid #c90;
}
.wrapper2 {
border: 2px solid #9c0;
overscroll-behavior-x: none;
}
p {
width: 500px;
}
Also see: Tab Triggers