メインコンテンツへスキップ

美少女イラスト&世界の国旗図鑑

    <!DOCTYPE html>
    <html lang="ja">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>美少女イラスト&世界の国旗図鑑</title>

    <style>
    *{
    margin:0;
    padding:0;
    box-sizing:border-box;
    }

    body{
    font-family:-apple-system,BlinkMacSystemFont,sans-serif;
    background:#121212;
    color:white;
    }

    header{
    text-align:center;
    padding:30px;
    background:#1e1e1e;
    position:sticky;
    top:0;
    z-index:100;
    }

    h1{
    margin-bottom:15px;
    }

    input{
    width:320px;
    max-width:90%;
    padding:12px;
    border:none;
    border-radius:8px;
    font-size:16px;
    }

    section{
    padding:30px;
    }

    .section-title{
    margin-bottom:20px;
    font-size:28px;
    }

    .grid{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
    gap:20px;
    }

    .card{
    background:#1e1e1e;
    border-radius:12px;
    overflow:hidden;
    transition:0.2s;
    }

    .card:hover{
    transform:translateY(-5px);
    }

    .card img{
    width:100%;
    display:block;
    }

    .card-title{
    padding:12px;
    text-align:center;
    font-weight:bold;
    }

    .flag img{
    aspect-ratio:3/2;
    object-fit:cover;
    }

    .illustration img{
    aspect-ratio:3/4;
    object-fit:cover;
    }

    footer{
    text-align:center;
    padding:40px;
    color:#999;
    }
    </style>
    </head>
    <body>

    <header>
    <h1>🌏 美少女イラスト&世界の国旗図鑑</h1>
    <input
    type="text"
    id="search"
    placeholder="国名を検索..."
    >
    </header>

    <section>
    <h2 class="section-title">🎨 美少女イラスト</h2>

    <div class="grid">

    <div class="card illustration">
    <img src="images/girl1.jpg" alt="美少女1">
    <div class="card-title">Character A</div>
    </div>

    <div class="card illustration">
    <img src="images/girl2.jpg" alt="美少女2">
    <div class="card-title">Character B</div>
    </div>

    <div class="card illustration">
    <img src="images/girl3.jpg" alt="美少女3">
    <div class="card-title">Character C</div>
    </div>

    <div class="card illustration">
    <img src="images/girl4.jpg" alt="美少女4">
    <div class="card-title">Character D</div>
    </div>

    </div>
    </section>

    <section>
    <h2 class="section-title">🏳️ 世界の国旗</h2>

    <div id="flags" class="grid"></div>
    </section>

    <footer>
    SVG Flag Data + Rest Countries API
    </footer>

    <script>
    const flagsContainer = document.getElementById("flags");
    const searchInput = document.getElementById("search");

    let countries = [];

    async function loadCountries(){

    const response = await fetch(
    "https://restcountries.com/v3.1/all?fields=name,cca2"
    );

    countries = await response.json();

    countries.sort((a,b)=>
    a.name.common.localeCompare(b.name.common)
    );

    renderFlags(countries);
    }

    function renderFlags(list){

    flagsContainer.innerHTML = "";

    list.forEach(country=>{

    const code = country.cca2.toLowerCase();

    const card = document.createElement("div");

    card.className = "card flag";

    card.innerHTML = `
    <img
    src="https://flagcdn.com/${code}.svg"
    alt="${country.name.common}"
    loading="lazy"
    >

    <div class="card-title">
    ${country.name.common}
    </div>
    `;

    flagsContainer.appendChild(card);
    });
    }

    searchInput.addEventListener("input",(e)=>{

    const keyword = e.target.value.toLowerCase();

    const filtered = countries.filter(country=>
    country.name.common
    .toLowerCase()
    .includes(keyword)
    );

    renderFlags(filtered);
    });

    loadCountries();
    </script>

    </body>
    </html>

    あなたへのおすすめ