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.
<!-- チェックボックス -->
<input type="checkbox" id="trg-close"><!--閉じるボタン-->
<input type="checkbox" id="popup"> <!--ポップアップ -->
<input type="checkbox" id="popup-close"> <!-- ポップアップ終了 -->
<!----- 閉じるボタン ----->
<label for="trg-close" class="circle-close">
<img src="https://skisitzmark.org/wp-content/uploads/2022/08/close-btn.png">
</label>
<!----- ポップアップを開くためのバナー ----->
<label for="popup" class="pup-trg">
<img src="https://gyaku-rape.com/wp-content/uploads/2022/08/sale-ban.png">
</label>
<!----- ポップアップ要素 ------>
<div class="pup-block">
<!-- 終了のためのラベル -->
<label for="popup-close">
<div class="pup-overlay"></div><!--オーバーレイ-->
<div class="close-btn">×</div> <!--閉じるボタン-->
</label>
<!-- ポップアップさせる内容 -->
<div class="pup-inner">
<!-- ここから -->
<p>サンプル<br>
夏の大特価セール</p>
<p>欲しかったあのゲームも漫画も大幅割引!!<br>
<span style="color:red">最大90%OFF!!</span></p>
<p>セール期間:8/1~8/10</p>
<a href="https://give-shot.jp/tokyocss">対象商品はこちら</a>
<!-- ここまで -->
</div>
</div>
<!----- 以下、サンプル用の装飾 ----->
<p>セールなどのお得な情報などを届けたい時に便利なブロックです。<br>
(3秒後に右下に出てきます)</p>
<p>ポップアップするのは一度だけで、閉じれば非表示になります。<br>
何度も何度も画面に表示されて鬱陶しく感じることもありません。</p>
<p>ちなみに、ポップアップを閉じるには、×ボタンをクリックするか、広告の範囲外をクリックしましょう。</p>
/*****************************
チェックボックス
*****************************/
/* バナーを閉じる */
#trg-close{
display: none;
}
/* ポップアップ */
#popup{
display: none; /*ユーザーに見せない*/
}
/* ポップアップ終了 */
#popup-close{
display: none; /*ユーザーには見せない*/
}
/************************
閉じるボタン
*************************/
/*ボタンの画像*/
.circle-close img{
width: 25px;
height: auto; /*25px*/
position: fixed;
bottom: calc(3% + (187px - 25px) - 5px) ; /** 3% + (バナーの高さ - ボタンの高さ) - 微調整 **/
right: calc(1% + 5px); /* 1% + 微調整 */
z-index: 1000; /*最前面*/
cursor: pointer; /*クリック可能のマウスポインター*/
opacity: 0; /*透明*/
visibility: hidden; /*非表示*/
animation: fadeIn .6s 5s ease forwards; /*フェードインで登場*/
}
/*** フェードインアニメーション ***/
@keyframes fadeIn{
0%{
opacity: 0; /*透明*/
visibility: hidden; /*非表示*/
}
100%{
opacity: 1; /*不透明*/
visibility: visible; /*表示*/
}
}
/*ボタンが押された or ポップアップしたら*/
#trg-close:checked ~ .circle-close, #popup:checked ~ .circle-close{
display: none; /*ボタンを削除*/
}
/***********************************
ポップアップする為のバナー
***********************************/
/*トリガー画像(label)*/
.pup-trg img{
position: fixed; /*固定表示*/
bottom: -300px; /*初期位置は画面外*/
right: 1%;
width: 300px; /*任意の幅(画像に合わせて)*/
height: auto; /*187px*/
cursor: pointer; /*クリック可能のカーソル*/
border-radius: 12px; /*丸み*/
box-shadow: 0 0 12px rgba(0,0,0,80%); /*影*/
animation: slideup .6s ease forwards; /*スライドして登場*/
animation-delay: 3s; /*登場を少し遅らせる*/
z-index: 999; /*閉じるボタンより背面*/
}
/*スライドするアニメーション*/
@keyframes slideup{
0%{
bottom: -300px; /*画面外から*/
}
100%{
bottom: 3%; /*画面内へ*/
}
}
/*ポップアップした or 閉じるボタンが押された*/
#popup:checked ~ .pup-trg, #trg-close:checked ~ .circle-close{
display: none; /*バナーを削除*/
}
/*****************************
ポップアップする要素
*****************************/
/*要素全体*/
.pup-block{
position: fixed; /*固定表示*/
top: 0;
left: 0;
width: 100%; /*画面幅*/
height: 100vh; /*画面の高さ*/
z-index: 999;
display: none; /*最初は非表示*/
}
/*バナーがクリックされたら*/
#popup:checked ~ .pup-block{
display: block; /*表示*/
}
/* オーバーレイ(画面を覆う背景) */
.pup-overlay{
width: 100%;
height: 100%;
background: rgba(0,0,0,50%);
}
/*ポップアップ終了用のボタン*/
.close-btn{
position: absolute;
top: 3%;
right: 3%; /*画面右上*/
color: #fff;
font-size: 30px;
cursor: pointer; /*クリック可能のカーソル*/
}
/*終了ボタン or オーバーレイをクリックしたら*/
#popup-close:checked ~ .pup-block{
display: none; /*ポップアップを削除*/
}
/* ボックス(広告部分) */
.pup-inner{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%); /*中央へ*/
min-width: 10%; /*幅の最低値(任意)*/
background: white; /*背景色*/
padding: 20px; /*内側の余白*/
box-shadow: 0 0 16px rgba(0,0,0,70%); /*影*/
}
/***************************
広告の装飾(サンプル用)
***************************/
.pup-inner p:nth-of-type(1){
font-size: 1.4em;
font-weight: bold;
}
.pup-inner a{
display: inline-block;
vertical-align: middle; /*上下中央寄せ*/
line-height: 1.5;
padding: 5px 30px;
border-radius: 4px;
background: #F37167;
color: #fff;
text-decoration: none;
box-shadow: 0 2px 0 #96150C;
transition: .3s;
}
.pup-inner a:hover{
transform: translateY(2px);
box-shadow: none;
}
/*** サンプル装飾用(使用時に削除) ***/
body{
text-align: center;
}
body > p{
font-size: 14px;
}
.pup-inner{
zoom: 0.65;
}
Also see: Tab Triggers