简体   繁体   中英

Can't link CSS to HTML in Github Pages

Im new to Github, when i open the website my html is showing without my css. Here is my html code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NFT-Card</title>
    <link rel="stylesheet" href="/nft.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap" rel="stylesheet">
</head>
<body>
    <div>
        <img id="mainImage" src="/NFT-Card/images/image-equilibrium.jpg" alt="">
        <h2>Equilibrium #3429</h2>
        <p id="paragraphExp">Our Equilibrium collection promotes balance and calm</p>
        <img id="ethIcon" src="/NFT-Card/images/icon-ethereum.svg" alt="">
        <p id="price">0.041ETH</p>
        <img id="clockImage" src="/NFT-Card/images/icon-clock.svg" alt="">
        <p id="clockText">3 days left</p>
        <hr>
        <img id="avatar" src="/NFT-Card/images/image-avatar.png" alt="">
        <p id="author">Creation of <b id="boldEl">Jules Wyvern</b></p>
    </div>
</body>
</html>

Here is my Github repository: https://github.com/Tonka12/tonka12.github.io

You can try to add a . befaure the / :

<link rel="stylesheet" href="./nft.css">

the css file and your html file are in the same folder. so the href should be:

<link rel="stylesheet" href="nft.css">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM