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.
<header id="header">
<div class="inner wrapper">
<h1 class="logo">
<a href="index.html"><img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-logo.png" alt="GSAPセミナー by りょーすけ@codolife6期生"></a>
</h1>
<nav>
<ul>
<li><a href="#news">NEWS</a></li>
<li><a href="#about">ABOUT</a></li>
<li><a href="#business">BUSINESS</a></li>
<li><a href="#company">COMPANY</a></li>
</ul>
</nav>
</div>
<a class="contact" href="#">お問い合わせ</a>
</header>
<main>
<div id="mainvisual">
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo.jpg">
<span class="mask"></span>
<div class="copy-wrapper">
<h2 class="copy">
<span>ア</span>
<span>二</span>
<span>メ</span>
<span>ー</span>
<span>シ</span>
<span>ョ</span>
<span>ン</span>
<span>付</span>
<span>与</span>
</h2>
<p>
<span class="green">G</span>
<span class="green">S</span>
<span class="green">A</span>
<span class="green">P</span>
<span>セ</span>
<span>ミ</span>
<span>ナ</span>
<span>ー</span>
</p>
</div>
</div>
<div class="top-container">
<section id="news" class="wrapper">
<h2 class="section-title">
<span class="en">NEWS</span>
<span class="ja">ニュース</span>
</h2>
<ul class="list">
<li>
<div class="date-area">
<time datetime="2021-01-01">2021.01.01</time>
<span>NEWS</span>
</div>
<p>タイトルタイトルタイトルタイトル</p>
</li>
<li>
<div class="date-area">
<time datetime="2021-01-01">2021.01.01</time>
<span>PRESS</span>
</div>
<p>タイトルタイトルタイトルタイトル</p>
</li>
<li>
<div class="date-area">
<time datetime="2021-01-01">2021.01.01</time>
<span>NEWS</span>
</div>
<p>タイトルタイトルタイトルタイトル</p>
</li>
</ul>
</section>
<section id="about">
<div class="img">
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-about.jpg">
</div>
<div class="text">
<h2 class="section-title">
<span class="en">ABOUT</span>
<span class="ja">私たちについて</span>
</h2>
<p>
テキストテキストテキストテキストテキストテキスト
テキストテキストテキストテキストテキストテキスト
</p>
<p>
テキストテキストテキストテキストテキストテキスト
テキストテキストテキストテキストテキストテキスト
</p>
<p>
テキストテキストテキストテキストテキストテキスト
テキストテキストテキストテキストテキストテキスト
</p>
</div>
</section>
<section id="business" class="wrapper">
<h2 class="section-title">
<span class="en">BUSINESS</span>
<span class="ja">事業内容</span>
</h2>
<div class="flex">
<div class="left">
<div class="item">
<p class="title">Web制作・マーケティング</p>
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-business01.jpg" alt="">
</div>
<div class="item">
<p class="title">インターネットメディア事業</p>
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-business02.jpg" alt="">
</div>
</div>
<div class="right">
<div class="item">
<p class="title">プロモーション企画・制作</p>
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-business03.jpg" alt="">
</div>
<div class="item">
<p class="title">ソーシャル企画・運営</p>
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-business04.jpg" alt="">
</div>
</div>
</div>
</section>
<section id="company" class="wrapper">
<div class="text">
<h2 class="section-title">
<span class="en">COMPANY</span>
<span class="ja">会社情報</span>
</h2>
<dl class="info">
<dt>会社名</dt>
<dd>ウェブエンターテイメントデザイン株式会社</dd>
<dt>所在地</dt>
<dd>東京都渋谷区桜丘町99-9 West Building 3F</dd>
<dt>代表</dt>
<dd>XXXXXX</dd>
<dt>設立</dt>
<dd>2021年1月1日</dd>
<dt>資本金</dt>
<dd>3,000,000円</dd>
<dt>事業内容</dt>
<dd>Web制作・マーケティング</dd>
<dd class="add">インターネットメディア事業</dd>
<dd class="add">プロモーション企画・制作</dd>
<dd class="add">ソーシャル企画・運営</dd>
</dl>
</div>
<div class="img">
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-company.jpg">
<span class="mask"></span>
</div>
</section>
</div>
</main>
<footer id="footer">
<div class="wrapper">
<div class="flex">
<div class="logo">
<img src="https://ryo-sukeblog.net/wp-content/uploads/2022/09/gsap-coding-demo-logo.png" alt="Web Entertainment Design">
</div>
<div class="info">
<p>
Web Entertainment Design Inc.<br>
West Building 3F<br>
9-99 Sakuragaokacho Shibuya-ku<br>
Tokyo, Japan 150-0031
</p>
<p>T/99-9999-9999</p>
</div>
</div>
<p class="copyright">© Web Entertainment Design Inc.</p>
</div>
</footer>
@charset "UTF-8";
html {
font-size: 100%;
}
body {
color: #000;
font-size: 0.875rem;
font-family: 'Noto Sans JP',sans-serif;
position: relative;
}
a {
color: #000;
font-size: 0.875rem;
text-decoration: none;
}
img {
max-width: 100%;
vertical-align: bottom;
}
li {
list-style: none;
}
.logo {
width: 100px;
line-height: 1px;
margin-right: 60px;
}
.logo a {
display: block;
}
.section-title {
font-weight: normal;
line-height: 1;
margin-bottom: 50px;
}
/*
疑似要素を使って下線を引く
*/
.section-title::after {
content: "";
width: 40px;
height: 1px;
background-color: #000;
display: block;
}
/*
「display: inline-block;」を設定してブロック化することで、
改行されてmargin-bottomが使用できるようになる
*/
.section-title .en {
display: block;
font-size: 2.25rem;
letter-spacing: 0.3em;
margin-bottom: 10px;
}
.section-title .ja {
display: block;
font-size: 0.875rem;
margin-bottom: 36px;
}
/*
横幅を設定するための共通クラス
*/
.wrapper {
width: 100%;
max-width: 1032px;
padding: 0 16px;
margin: 0 auto;
}
/*-------------------------------------------
ヘッダー
-------------------------------------------*/
#header {
width: 100%;
height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin: 0 auto;
transform: translate(0,-100%);
}
#header .inner {
display: flex;
align-items: center;
}
#header .inner ul {
display: flex;
align-items: center;
}
#header .inner li {
margin-right: 30px;
}
#header .inner li:last-child {
margin-right: 0;
}
#header .contact {
width: 200px;
height: 80px;
line-height: 80px;
background-color: #000;
color: #fff;
font-size: 0.75rem;
display: inline-block;
text-align: center;
}
#header .contact:hover {
background-color: #333;
}
/*-------------------------------------------
Mainvisual
-------------------------------------------*/
#mainvisual {
margin-bottom: 100px;
position: relative;
}
#mainvisual .mask{
content:'';
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(0,0,0,.25);
opacity: 0;
}
.copy-wrapper{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: white;
}
.copy-wrapper h2{
font-size: 72px;
letter-spacing: .1em;
display: flex;
will-change: transform,opacity;
overflow: hidden;
}
.copy-wrapper span{
display: block;
will-change: transform,opacity;
font-weight: 600;
}
.copy-wrapper h2 .pad{
padding-left: 12px;
}
.copy-wrapper p{
font-size: 50px;
font-weight: 500;
letter-spacing: .1em;
overflow: hidden;
}
.copy-wrapper p{
display: flex;
}
.copy-wrapper span{
display: block;
}
/*
メインビジュアルを画面の高さに合わせる
headerの高さが80pxあるので、100vhから80px分だけマイナスする
*/
#mainvisual img {
width: 100%;
height: 100vh;
object-fit: cover;
opacity: 0;
}
/* container */
.top-container{
width: 100%;
height: fit-content;
background-color: #f0f0f0f0;
padding-top: 20px;
}
/*-------------------------------------------
News
-------------------------------------------*/
#news {
margin-bottom: 120px;
}
#news .list {
display: flex;
justify-content: space-between;
}
/*
「width: calc(100%/3);」で横幅を3等分する
*/
#news .list li {
width: calc(100%/3);
border-right: solid 1px #000;
padding: 10px 20px;
}
#news .list li:first-child {
padding-left: 0;
}
#news .list li:last-child {
border-right: none;
padding-right: 0;
}
#news .list li .date-area {
margin-bottom: 16px;
}
#news .list li .date-area span {
width: 50px;
height: 20px;
line-height: 20px;
background-color: #000;
color: #fff;
display: inline-block;
font-size: 0.75rem;
margin-left: 10px;
text-align: center;
}
/*-------------------------------------------
About
-------------------------------------------*/
#about {
display: flex;
margin-bottom: 120px;
}
#about .img {
width: 55%;
height: 400px;
overflow: hidden;
}
#about .img img {
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1.5);
}
#about .text {
width: 45%;
padding: 180px 5% 0 5%;
}
#about .text p {
line-height: 2.2;
}
/*-------------------------------------------
Business
-------------------------------------------*/
#business {
margin-bottom: 120px;
}
#business .flex {
display: flex;
justify-content: space-between;
padding: 0 10%;
}
#business .flex .left {
width: 46%;
margin-top: 100px;
}
#business .flex .right {
width: 46%;
}
#business .flex .item {
margin-bottom: 50px;
}
#business .flex .item:last-child {
margin-bottom: 0;
}
#business .flex .title {
font-weight: bold;
margin: 0 0 10px 18px;
position: relative;
}
/*
疑似要素でタイトルの横線を引く
*/
#business .flex .title::before {
content: "";
width: 8px;
height: 1px;
background-color: #000;
position: absolute;
top: 50%;
left: -18px;
}
/*-------------------------------------------
Company
-------------------------------------------*/
/*
テキストと画像はpositionを使って配置
子要素の「position: absolute;」で高さがなくなるため、
「height: 750px;」を指定して高さを確保
*/
#company {
height: 750px;
display: flex;
align-items: center;
position: relative;
}
#company .text {
width: 55%;
background-color: #fff;
padding: 100px 8% 100px 6%;
position: absolute;
top: 0;
left: 0;
}
#company .img {
width: 53%;
height: 400px;
position: absolute;
top: 115px;
right: 0;
overflow: hidden;
}
#company .img img {
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0;
}
#company .img .mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
display: block;
will-change: transform;
transition-property:transform;
}
#company .info {
display: flex;
align-items: center;
flex-wrap: wrap;
}
#company .info dt {
width: 20%;
margin-top: 10px;
}
/*
1つめのdtにはmargin-topを設定しない
*/
#company .info dt:first-of-type {
margin-top: 0;
}
#company .info dd {
width: 80%;
margin-top: 10px;
}
/*
1つめのddにはmargin-topを設定しない
*/
#company .info dd:first-of-type {
margin-top: 0;
}
#company .info .add {
margin-left: 20%;
}
/*-------------------------------------------
footer
-------------------------------------------*/
#footer {
background-color: #fff;
padding-bottom: 20px;
}
#footer .flex {
display: flex;
align-items: center;
justify-content: space-between;
padding: 40px 0;
}
#footer .flex .logo {
margin-right: 0;
}
#footer .copyright {
font-size: 0.625rem;
}
/*-------------------------------------------
SP
-------------------------------------------*/
@media screen and (max-width: 900px) {
.logo {
width: 80px;
margin: 8px 0;
}
.section-title {
margin-bottom: 34px;
}
.section-title .ja {
margin-bottom: 24px;
}
/*-------------------------------------------
ヘッダー
-------------------------------------------*/
#header .inner {
flex-direction: column;
align-items: flex-start;
}
#header .contact {
display: none;
}
/*-------------------------------------------
Mainvisual
-------------------------------------------*/
#mainvisual {
margin-bottom: 80px;
}
/*-------------------------------------------
News
-------------------------------------------*/
#news {
margin-bottom: 80px;
}
#news .list {
flex-direction: column;
}
#news .list li {
width: 100%;
border-right: none;
padding: 10px 0;
margin-bottom: 20px;
}
#news .list li:last-child {
margin-bottom: 0;
}
/*-------------------------------------------
About
-------------------------------------------*/
#about {
flex-direction: column;
margin-bottom: 80px;
}
#about .img {
width: 100%;
margin-bottom: 30px;
transform-origin: bottom;
}
#about .img img {
height: 300px;
}
#about .text {
width: 100%;
padding: 0 16px;
}
/*-------------------------------------------
Business
-------------------------------------------*/
#business {
margin-bottom: 80px;
}
#business .flex {
flex-direction: column;
padding: 0;
}
#business .flex .left {
width: 100%;
margin: 0 0 30px 0;
}
#business .flex .right {
width: 100%;
}
#business .flex .item {
text-align: center;
margin-bottom: 30px;
}
#business .flex .title {
text-align: left;
}
/*-------------------------------------------
Company
-------------------------------------------*/
/*
「position: static;」でrelativeを解除
*/
#company {
height: auto;
flex-direction: column;
position: static;
}
/*
「position: static;」でabsoluteを解除
*/
#company .text {
width: 100%;
padding: 40px 20px;
margin-bottom: 20px;
position: static;
}
/*
「position: static;」でabsoluteを解除
*/
#company .img {
width: 100%;
padding: 0;
position: relative;
top: 0;
}
#company .info {
flex-direction: column;
}
#company .info dt {
width: 100%;
margin-top: 20px;
}
#company .info dd {
width: 100%;
margin-top: 5px;
padding-left: 14px;
}
#company .info dd:first-of-type {
margin-top: 5px;
}
#company .info .add {
margin-left: 0;
}
/*-------------------------------------------
footer
-------------------------------------------*/
#footer .flex {
flex-direction: column;
align-items: flex-start;
}
#footer .flex .logo {
margin-bottom: 10px;
}
}
window.addEventListener('load',function(){
gsap.registerPlugin(ScrollTrigger);
/* OPENING ANIMATION PATTERN01 */
const openingTL = gsap.timeline({delay:.2});
openingTL
.to('#mainvisual img',{autoAlpha:1,duration:1.2})
.set('#mainvisual .mask',{autoAlpha:1},'<')
.fromTo('#mainvisual h2',{autoAlpha:0,scale:1.1},{autoAlpha:1,scale:1})
.fromTo('#mainvisual p',{autoAlpha:0,scale:1.2},{autoAlpha:1,scale:1})
.fromTo('#header',{y:'-100%'},{y:'0%'})
/* OPENING ANIMATION PATTERN02 */
// const openingTL = gsap.timeline({delay:.2});
// openingTL
// .to('#mainvisual img',{autoAlpha:1,duration:1.2})
// .set('#mainvisual .mask',{autoAlpha:1},'<')
// .fromTo('#mainvisual h2 span',{y:'100%'},{y:'0%',stagger:.035})
// .fromTo('#mainvisual p span',{y:'100%'},{y:'0%',stagger:.05},'>-.5')
// .to('#header',{y:'0%'})
})
Also see: Tab Triggers