简体   繁体   中英

Problem linking HTML to CSS even if link href is done, files are in the same folder

trying to start my coding journey and bumped into a problem. Got 2 pieces of text, one html and one css and I can't manage to link them together. Here they are:

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/css-stuff.css">  
  </head>
  <body bgcolor = brown>
  <div class = "container">
    <img src="https://ih0.redbubble.net/image.427712605.8856/flat,750x,075,f-pad,750x1000,f8f8f8.jpg">
  <form id="outsideBox" method = "post">
    <ul style="list-style-type:none;">
      <li>
      <label for "email">Email: </label>
      <input type = "text" id="email" name="email_adress">
      </li>
      <li>
        <label for "password">Password</label>
        <input type = "text" id="password" name="pw_input">
      </li>
      <li class = "button">
        <button id="clickMe" type = "button"> Login</button>
      </li>
    </ul>
    </form> </div>
  </html>

and css:

body{
  background-image: url(https://images.unsplash.com/photo-1518839283416-0cc546d12a97?ixlib=rb-1.2.1&w=1000&q=80);
  background-repeat: round;
}
.container{

  background-image: url(https://img.pngio.com/purple-background-png-png-group-romolagaraiorg-1920_1080.png);
  /* form position */
  position: relative;
  top: 100px;
  left: 600px;
  /*---------------*/
  width: 267px;
  border-style: outset;
  padding: 10px;
  border-radius: 1em;
  display: inline-block;
  text-align: right
}
img{
  width:100px;
  height: 100px;
  border-radius: 50%;
  margin-right: 75px
  }
ul{
  color:white;
}

Here are the two of them, they worked on codepen but wont compile in atom.

In your htlm file, inside head try to remove the '/' on the href css path, both files are in the same file directory.

Like this:
<link rel="stylesheet" type="text/css" href="css-stuff.css"/>

You should put the dots and slash in the same sequence. Like this:

<link rel="stylesheet" href="./css-stuff.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