はじめてのHTML/CSS②

HTML/CSS

【はじめてのHTML/CSS Part2】 HTML/CSS&ハンバーガーメニューの作り方 こうやれば必ずできます!

HTML/CSS設計図

ソースコード

HTML

index.html

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>リストデータ</title>
    <link rel="stylesheet" href="style.css">
    
</head>
<body>
   <header>
    <div class="container header-inner">
        <h1>Rei住宅</h1>
        <!-- <div class="header-wrapper"> -->
            <ul class="header-list">
                <li><a href="#">買いたい</a></li>
                <li><a href="#">売りたい</a></li>
                <li><a href="#">借りたい</a></li>
                <li><a href="#">貸したい</a></li>
                <li><a href="#">リフォーム</a></li>
                <li><a href="#">お気に入り</a></li>
            </ul>
        <!-- </div> -->
    </div>
   </header>

   <main class="container">
    <p class="result-cnt">
       <span class="kensu">8</span>件
    </p>

    <ul class="card">
        <li class="card-item">
            <a href="#" class="item">
                <div class="meisyo">
                    <p class="tn">パーク・ハイムRei</p>
                    <p class="label">マンション</p>
                </div>
                <div class="bukken">
                    <img src="img/house1.jpg" alt="パーク・ハイムRei">
                    <div class="meisai">
                        <div class="cost1">
                            <p><span class="price">14.8</span>万円 /</p>
                        
                            <dl class="kanrihi">
                                <dt> 管理費</dt>
                                <dd>-</dd>
                            </dl>
                        </div><!-- cost1 -->

                        <div class="cost2">
                            <p>敷金 1ヶ月</p>
                            <p>礼金 2ヶ月</p>
                        </div><!-- cost2 -->

                        <div class="cost3">
                            <dl class="grid-item">
                                <dt>所在地</dt>
                                <dd>兵庫県芦屋市*****町</dd>
                            </dl>
                            <dl class="grid-item">
                                <dt>交通</dt>
                                <dd>東海道本線「芦屋」駅 徒歩14分</dd>
                            </dl>
                            <div class="koumoku">
                                <dl class="grid-item">
                                    <dt>間取り</dt>
                                    <dd>2LDK</dd>
                                </dl>
                                <dl class="grid-item">
                                    <dt>向き</dt>
                                    <dd>-</dd>
                                </dl>
                                <dl class="grid-item">
                                    <dt>専有面積</dt>
                                    <dd>65.19m</dd>
                                </dl>
                                <dl class="grid-item">
                                    <dt>築年月</dt>
                                    <dd>1987年3月</dd>
                                </dl>
                                <dl class="grid-item">
                                    <dt>構造</dt>
                                    <dd>鉄筋コンクリート</dd>
                                </dl>
                                <dl class="grid-item">
                                    <dt>所在階</dt>
                                    <dd>1階/9階建</dd>
                                </dl>
                            </div>
                        </div><!--cost3  -->
                    </div><!-- meisai -->
                </div><!--bukken  -->

                <div class="comment">
                    <p class="card-text">
                        家から80mの場所に芦屋翠ケ丘郵便局があります。
                        セキュリティ面は、オートロック・TVインターホンなどを
                        備え付けているので安心して暮らせます。化粧品やスタイ
                        リング剤などをまとめて出し入れして、サッと身支度を整
                        えられる独立洗面台があります。こだわりの条件として好
                        評の、フローリングの物件です。設備のグレードが高い分
                        譲賃貸、快適な住まいに住んでみませんか。芦屋市に特化
                        した当社は、確かな地域情報と豊富な賃貸情報を取り扱っ
                        ています。知識をあまりお持ちでない方にも親切にサポー
                        ト致しますので、ぜひお部屋探しは当社にお任せ下さい。
                    </p>
                </div><!-- comment -->
            </a>
            <ul class="content-wraper">
                <li class="btn-items">
                    <a href="#" class="link-standard">物件詳細</a>
                </li>
                <li class="btn-items">
                    <a href="#" class="link-standard contact">お問い合わせ</a>
                </li>
            </ul>
        </li><!-- card-item -->

                ~
             物件数分データ

  </ul><!-- card -->
   </main>

   <aside>
        <div class="container">
            <h2>INFORMATION</h2>
            <p>テキストテキストテキストテキストテキストテキスト</p>
            <img src="img/家アイコン.png" alt="アイコン">
            <div class="button">
                <a href="https://rei-excel-channnel.com/youtubevbatop/">ブログも見てね!</a>
            </div>
        </div>
   </aside>

   <footer>
    <div class="container">
        <small>©Reiチャンネル</small>
    </div>
   </footer>
</body>
</html>

CSS

style.css

@charset "UTF-8";
/*      */
/* html */
/*      */

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    font-size: 14px;
    background-color: #F5F5F5;
    color: #112B40;

}
.container{
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
    align-items: center;
}
ul{
    list-style: none;
}
a{
    text-decoration: none;
    color: #112B40;
}
a:hover{
    transition: 0.4s;
    opacity: 0.7;
}
/*         */
/* header  */
/*         */
header{
    background-color: white;
}
header h1{
    font-size: 35px;
}
header .header-inner{
    height: 80px;
    font-weight: 600;
    display: flex;
    /* justify-content: space-between; */
}
header .header-list{
    font-size: 16px;
    display: flex;
    gap: 40px;
    margin: 0 0 0 auto;
}
/*       */
/* main  */
/*       */
.result-cnt{
    text-align: left;
    font-size: 24px;
    color: #7c786e;
    font-weight: 700;
    border-bottom: solid 1px #d5d5d5;
    font-family: "Shippori Mincho B1", serif;
    margin-bottom: 43px;
}
.kensu{
    font-size: 40px;
    color: #d2bd6d;
}
/*       */
/*  card */
/*       */
.card{
    display: grid;
    gap: 30px;
    margin-bottom: 66px;
}
.card-item{
    background-color: white;
    border-radius: 10px;
    padding: 25px 0;
    box-shadow: 10px 10px 10px -10px;
}
.meisyo{
    text-align: left;
    color: #656565;
    padding: 20px;
    border-bottom: solid 1px #cdcdcd;
    font-family:"Shippori Mincho B1", serif;
    display: flex;
    align-items: center;
}
.tn{
    font-size: 24px;
    margin-right: 27px;
    font-weight: 600;
}
.label{
    font-size: 14px;
    height: 24px;
    background-color: #ececec;
    border-radius: 3px;
    padding: 0 10px;
}
.bukken{
    display: flex;
    gap: 20px;
    padding: 20px 20px 18px;
    font-family:"Zen Kaku Gothic New", sans-serif;
}
.bukken img{
    width: 420px;
    height: 270px;
}
/*        */
/* meisai */
/*        */
.meisai{

}
.cost1{
    font-size: 16px;
    font-weight: 700;
    display: flex;
    font-family: "Shippori Mincho B1", serif;
    align-items: baseline;
}
.cost1 .price{
    font-size: 36px;
    color: #d2bd6d;
    font-weight: 500;
    margin-right: 5px;
}
.kanrihi{
    display: flex;
}
.cost2{
    display: flex;
    font-size: 14px;
    font-weight: 400;
    gap: 12px;
    margin-bottom: 24px;
}
.cost3{
    display: grid;
    width: 420px;
    row-gap: 12px;
    text-align: left;
}
.grid-item{
    display: flex;
}
.cost3 dt{
    width: 76px;
}
.cost3 dd{
    font-size: 15px;
    font-weight: 500;
    color: #6d6d6d;
}
.koumoku{
    display: grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 12px;
}
/*        */
/* comment */
/*        */
.comment{
    font-size: 16px;
    background-color: #f3f3f3;
    margin: 20px;
    padding: 10px 15px;
    text-align: left;
}
.card-text{
    color: #656565;
    font-weight: 350;
    letter-spacing: 1px;

    display: -webkit-box;
  -webkit-box-orient:vertical ;/* 垂直方向に配置 */

    /* overflow: auto; */
    -webkit-line-clamp:2;        /* 最大行数を2行に設定 */
     overflow: hidden;            /* 溢れた部分を隠す */


}
/*         */
/* content */
/*         */
.content-wraper{
    font-size: 18px;
    font-family: "Shippori Mincho B1", serif;
    font-weight: 600;
    display: flex;
    gap: 10px;
    margin: 0 20px;
}
.btn-items{
    width: 100%;
}
.link-standard{
    color: #565e7d;
    border: 1px solid #565e7d;
    padding: 12px 0;
    display: block;
}
.contact{
    background-color: #565e7d;
    color: white;
}
 /*       */
 /* aside */
 /*       */
 aside{
    padding: 10px 0;
 }
 aside h2{
    font-size: 36px;
    margin-bottom: 20px;
 }
 aside img{
    width: 100px;
    margin-bottom: 20px;
 }
 aside .button{
    margin: 20px;
 }
 aside .button a{
    background-color: #434c6c;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
 }
 aside .button a:hover{
    background-color: white;
    color: #434c6c;
 }
/*        */
 /* footer */
 /*        */
footer{
    background-color: white;
    padding: 10px;
}

ハンバーガーメニュー①

設計図

ソースコード

HTML

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style2.css">

    
</head>
<body>
    <header>
        <div class="container header-inner">
            <h1>Rei住宅</h1>
            <div class="header-wrapper">
                <!-- <nav> -->
                    <ul class="header-list">
                        <li><a href="">買いたい</a></li>
                        <li><a href="">売りたい</a></li>
                        <li><a href="">借りたい</a></li>
                        <li><a href="">貸したい</a></li>
                        <li><a href="">リフォーム</a></li>
                        <li><a href="">お気に入り</a></li>
                    </ul>
                <!-- </nav> -->
            </div><!--header-wrapper  -->
         </div><!--container header-inner  -->
        <div class="btn">
            <span></span>
            <span></span>
            <span></span>
        </div>
    </header>

    <nav>
        <ul class="over-wrap">
            <li><a href="">買いたい</a></li>
            <li><a href="">売りたい</a></li>
            <li><a href="">借りたい</a></li>
            <li><a href="">貸したい</a></li>
        </ul>
    </nav>

    <main>

    </main>
     <script src="script.js"></script>

  </body>
</html>

CSS

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    font-size: 14px;
    color: #66599a;
    background-color: #f7f5f5;
}
.container{
    width:900px ;
    margin: 0 auto;
}
a{
    text-decoration: none;
}
ul{
    list-style: none;
}
/*        */
/* header */
/*        */
header{
    background-color: white;
    min-width: 260px;
    height: 80px;
    text-align: center;
}
header .header-inner{
    display: flex;
    line-height: 80px;
    justify-content: space-between;
}
header .header-list{
    display: flex;
    list-style: none;
    align-items: center;
    gap: 40px;
    justify-content: flex-end;
}
header .header-wrapper{
    display: flex;
    margin: 0 0 0 auto;
}
header li{
    padding-left: 15px;
    
}
header a{
    text-decoration: none;
    color: #434c6c;
    font-weight: 600;
}
/*     */
/* btn */
/*     */
.btn{
    position: fixed;
    /* display: block; */
    top: 20px;
    text-align: center;
    right: 10px;
    width: 40px;
    /* width: 60px; */
    height: 40px;
    /* background-color: #e9e9e1; */
    z-index: 2;
    /* gap: 12px; */
}
.btn span{
    position: absolute;
    right: 10px;
    width: 20px;
    height: 2px;
    /* width: 40px; */
    /* height: 2px; */
    /* background-color: white */
    background-color: #112b40;
    transition: 0.8S;


}
.btn span:nth-child(1) {
    top: 10px;
    /* transition: 0.8S; */

    /* top: 20px; */
}
.btn span:nth-child(2) {
    top: 20px;
    /* top: 30px; */

}
.btn span:nth-child(3) {
    top: 30px;
    /* transition: 0.8S; */

    /* top: 40px; */
}
.btn.show span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
    background-color: white;
    transition: 0.8S;
}
.btn.show span:nth-child(2) {
    opacity: 0;
}
.btn.show span:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
    background-color: white;
    transition: 0.8S;
}
/*           */
/* over-wrap */
/*           */
.over-wrap{
    display: block;
    min-width: 340px;
    position: fixed;
    background-color:#434c6c;
    top: 0;
    right: -340px;
    bottom: 0;
    padding: 60px 35px;
    transition: 0.5s;
    z-index: 1;
}
.over-wrap li{
    margin-bottom: 25px;
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.over-wrap a{
    color:white;
}
.over-wrap.show{
    right: 0;
}

java script

"use strict";
{
    const btn=document.querySelector('.btn');
    const overwrap=document.querySelector('.over-wrap');

     btn.onclick =() => {
        btn.classList.toggle('show');
        overwrap.classList.toggle('show');
     }
}

ハンバーガーメニュー②

設計図

ソースコード

HTML

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style4.css">

</head>
<body>
    <header>
        <div class="container header-inner">
            <h1>Rei住宅</h1>
            <div class="header-wrapper">
                    <ul class="header-list">
                        <li><a href="">買いたい</a></li>
                        <li><a href="">売りたい</a></li>
                        <li><a href="">借りたい</a></li>
                        <li><a href="">貸したい</a></li>
                        <li><a href="">リフォーム</a></li>
                        <li><a href="">お気に入り</a></li>
                    </ul>
            </div>
            <div class="btn">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div><!--header-inner  -->
    </header>

    <div class="over-wrap">
        <nav>
            <ul >
                <li><a href="">買いたい</a></li>
                <li><a href="">売りたい</a></li>
                <li><a href="">借りたい</a></li>
                <li><a href="">貸したい</a></li>
            </ul>
        </nav>
        <div class="btn-close">
            <span>✖</span>
        </div>
    </div>

    <main>

    </main>
     <script src="script2.js"></script>

  </body>
</html>

CSS

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    font-size: 14px;
    color: #66599a;
    background-color: #f7f5f5;
}
.container{
    width:900px ;
    margin: 0 auto;
    align-items: center;
}
a{
    text-decoration: none;
}
ul{
    list-style: none;

}
/*        */
/* header */
/*        */
header{
    background-color: white;
    height: 80px;
    text-align: center;
}
header .header-inner{
    display: flex;
    /* line-height: 80px; */
    height: 80px;
    justify-content: space-between;
    /* justify-content: space-around; */
    /* background-color: rgb(0, 213, 255); */
}
header .header-list{
    display: flex;
    list-style: none;
    /* align-items: center; */
    gap:30px;
}
header .header-wrapper{
    display: flex;
}
header .header-list li{
    padding-left: 15px;
    
}
header a{
    text-decoration: none;
    color: #434c6c;
    font-weight: 600;
}
/*     */
/* btn */
/*     */
.btn{
    position: relative;
    width: 40px;
    height: 40px;
    /* background-color: rgb(232, 232, 134); */
    /* z-index: 2; */
}
.btn span{
    position: absolute;
    width: 20px;
    height: 2px;
    right: 10px;
    display: block;
    background-color:  #112b40;
    opacity: 0;
}
.btn span:nth-child(1) {
    top: 10px;
}
.btn span:nth-child(2) {
    top: 20px;
}
.btn span:nth-child(3) {
    top: 30px;
}
/* .btn.show span:nth-child(1) {
    right: 10%;
    transform: translateY(10px) rotate(45deg);
    background-color: white;
    opacity: 0;
}
.btn.show span:nth-child(2) {
    opacity: 0;
}
.btn.show span:nth-child(3) {
    left: 150px;
    transform: translateY(-10px) rotate(-45deg);
    background-color: white;
    opacity: 0;
} */
/*           */
/* over-wrap */
/*           */
.over-wrap{
    display: block;
    min-width: 340px;
    position: fixed;
    background-color:#434c6c;
    top: 0;
    right: -340px;
    bottom: 0;
    padding: 60px 35px;
    transition: 0.3s;
    z-index: 1;
    color: white;
}
.over-wrap li{
    margin-bottom: 25px;
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid lab(50% 0.01 -0.01);
}
.over-wrap a{
    color:white;
}
.over-wrap.show{
    right: 0;
}
.btn-close{
    position: absolute;
    /* width: 20px; */
    /* height: 20px; */
    top: 20px;
    right:30px;
    color: white;
}
.btn-close span{
    font-size: 30px;
}

java script

"use strict";
{
    const btn=document.querySelector('.btn');
    const btnclose=document.querySelector('.btn-close');
    const overwrap=document.querySelector('.over-wrap');

     btn.onclick = () => {

        btn.classList.toggle('show');
        overwrap.classList.toggle('show');

    } ;
    btnclose.onclick = () => {

        btn.classList.toggle('show');
        overwrap.classList.toggle('show');

    } ;
}

スクレイピングテスト

以下の動画の VBAのurlに指定してお使いください

【リストデータ用】 https://rei-excel-channnel.com/scrapinglistdata/

コメント