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.
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--==============レイアウトを制御する独自のCSSを読み込み===============-->
<link href="https://assets.codepen.io/6329135/reset04.css" rel="stylesheet">
</head>
<body>
<header id="header">
<h1>WEB先案内<br>名言コレクション</h1>
<div id="header-img"></div>
<div class="scrolldown"><span>Scroll</span></div>
</header>
<main id="container">
<section>
<h2>名言 1</h2>
<p>人はそれぞれ事情をかかえ、平然と生きている</p>
<p>ベストを尽くして失敗したら、ベストを尽くしたってことさ</p>
<p>いちばんいけないのはじぶんなんかだめだと思いこむことだよ</p>
<p>この世に生を受けたこと。それ自体が最大のチャンスではないか</p>
<!--/area1-->
</section>
<section>
<h2>名言 2</h2>
<p>ろくな晩じゃねぇや。寝ちまえ、寝ちまえ。寝て起きりゃ別の日だ</p>
<p>世の中ってオレより頭のいい人のほうが多いんだ</p>
<p>何かを捨てないと前に進めない</p>
<p>弱気は最大の敵</p>
<!--/area2-->
</section>
<section>
<h2>名言 3</h2>
<p>いつか、必ず、チャンスの順番が来ると信じなさい</p>
<p>前向きにもがき苦しむ経験は、すぐに結果に結びつかなくても、必ず自分の生きる力になっていく</p>
<p>「ゴールは遠いなぁ」と、がっかりするのも道のりです</p>
<p>「負けたことがある」というのが いつか 大きな財産になる</p>
<!--/area3-->
</section>
<section>
<h2>名言 4</h2>
<p>前進できぬ駒はない</p>
<p>「仕事はナメてかかって、真面目にやれ」と思っている。俺は、どの仕事もそうしてきているんです</p>
<p>自分を少し抑えて、肩の力を抜けば、仕事は長続きする</p>
<p>常に今日は明日の準備ですからね。今日やったことは必ず明日に返ってくるんです</p>
<!--/area4-->
</section>
<section>
<h2>名言 5</h2>
<p>強い者が勝つのではない。勝った者が強いのだ</p>
<p>自分がわかっていないことがわかるということが一番賢いんです</p>
<p>成功の反対は失敗ではなく「やらないこと」だ</p>
<p>自分が幸せかどうかは、自分で決めるしかないのよ</p>
<!--/area5-->
</section>
<!--/main-->
</main>
<footer id="footer">
<small>© copyright.</small>
</footer>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
</body>
@charset "utf-8";
#header {
position: relative; /*背景を設定するdivの基点とするためrelativeをかける*/
width: 100%;
height: 100vh;
overflow: hidden; /*はみ出しているところを隠す*/
}
#header-img {
position: fixed; /*背景を固定するためfixedをかける*/
z-index: 1; /*#container,#footerよりも下に配置するために数値を小さくする*/
top: 0; /*topの位置がJSで変化*/
/*以下画面で背景画像を表示させるための指定*/
width: 100%;
height: 100vh;
background: url("https://assets.codepen.io/6329135/wise-saying.jpg") no-repeat
top center; /*背景画像の設定*/
background-size: cover;
transform-origin: center; /*変化する基点を中心からに設定*/
filter: blur(3px);
}
#container,
#footer {
position: relative; /*#header-imgよりも配置を上にするためにrelativeをつける*/
z-index: 2; /*#header-imgよりもz-indexの値を大きな数値にして上に表示*/
}
/*========= スクロールダウンのためのCSS ===============*/
/*スクロールダウン全体の場所*/
.scrolldown {
/*描画位置※位置は適宜調整してください*/
position: absolute;
bottom: 10px;
right: 50%;
/*マウスの動き1.6秒かけて動く永遠にループ*/
animation: mousemove 1.6s ease-in-out infinite;
}
/*下からの距離が変化して上から下に動く*/
@keyframes mousemove {
0% {
bottom: 10px;
}
50% {
bottom: 5px;
}
100% {
bottom: 10px;
}
}
/*Scrollテキストの描写*/
.scrolldown span {
z-index: 10;
/*描画位置*/
position: absolute;
left: -15px;
bottom: 45px;
/*テキストの形状*/
color: #fff;
font-size: 0.7rem;
letter-spacing: 0.05em;
white-space: nowrap;
}
/*マウスの中の線描写 */
.scrolldown span::after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
top: 10px;
left: 17px;
/*線の形状*/
width: 1px;
height: 15px;
background: #fff;
/*線の動き1.4秒かけて動く。永遠にループ*/
animation: mousepathmove 1.4s linear infinite;
opacity: 0;
}
/*上からの距離・不透明度・高さが変化して上から下に流れる*/
@keyframes mousepathmove {
0% {
height: 0;
top: 10px;
opacity: 0;
}
50% {
height: 15px;
opacity: 1;
}
100% {
height: 0;
top: 30px;
opacity: 0;
}
}
/*マウスの描写 */
.scrolldown:before {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 0;
left: -10px;
/*マウスの形状*/
width: 25px;
height: 37px;
border-radius: 10px;
border: 1px solid #fff;
}
/*マウスの中の丸の描写*/
.scrolldown:after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 26px;
left: 0;
/*丸の形状*/
width: 5px;
height: 5px;
border-radius: 50%;
border: 1px solid #fff;
}
/*========= レイアウトのためのCSS ===============*/
#header h1 {
color: #fff;
font-size: 2rem;
text-align: center;
text-shadow: 2px 2px 2px #333;
text-transform: uppercase;
letter-spacing: 0.1em;
/*天地中央に配置*/
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2; /*#header-imgよりも手前に配置*/
}
#container h2 {
font-size: 1.2rem;
}
#container p {
margin-top: 20px;
}
#footer {
background: #333;
color: #fff;
display: block;
text-align: center;
padding: 20px;
}
section {
background: #fff;
padding: 30px;
}
section:nth-of-type(2n + 1) {
background: #eee;
}
$(window).scroll(function () {
var scroll = $(window).scrollTop(); //スクロール値を定義
//header-imgの背景
$("#header-img").css({
transform: "scale(" + (100 + scroll / 10) / 100 + ")", //スクロール値を代入してscale1から拡大.scroll/10の値を小さくすると拡大値が大きくなる
top: -(scroll / 50) + "%" //スクロール値を代入してtopの位置をマイナスにずらす
});
});
Also see: Tab Triggers