问题与CSS样式表功能有关。

huangapple go评论61阅读模式
英文:

Problem with CSS style sheet functionaltiy

问题

我在VS Code中创建一个HTML页面,并尝试为一个div元素添加样式,但是我的CSS样式表中的设置似乎都不起作用。

我已经确认我的HTML文件正在引用CSS文件,并且通过W3C CSS验证器运行了CSS代码。

HTML

<!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">
    <link rel="stylesheet" type="text/css" href="/Untitled/csss/style.css">
    <title>License Manager</title>
</head>
<body>
    <div class="login">
        <textarea rows="1" cols="20">
            password
        </textarea>
        <button>
            Authenticate
        </button>
    </div>
</body>
</html>

CSS

body {
    background-color: gray;
}

.login {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    border-width: 10px;
    border-color: black;
}
英文:

I'm creating an HTML page in VS Code and trying to style a div, however none of the settings in my CSS stylesheet seem to be working.

I have confirmed my HTML is referencing the CSS file and ran the CSS code through the W3C CSS validator.

HTML

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;link rel=&quot;sytlesheet&quot; type=&quot;text/css&quot; href=&quot;/Untitled/csss/style.css&quot;&gt;
    &lt;title&gt;License Managert&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class=&quot;login&quot;&gt;
        &lt;textarea rows=&quot;1&quot; cols=&quot;20&quot;&gt;
        password
        &lt;/textarea&gt;
        &lt;button&gt;
        Authenticate
        &lt;/button&gt;
    &lt;/div&gt; 
&lt;/body&gt;
&lt;/html&gt;

CSS

body{
    background-color: gray;
}

.login{
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    border-width: 10px;
    border-color: black;
}

答案1

得分: 0

更改:

&lt;link rel=&quot;sytlesheet&quot; type=&quot;text/css&quot; href=&quot;/Untitled/csss/style.css&quot;&gt;

为:

&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/Untitled/csss/style.css&quot;&gt;

你拼错了 "stylesheet"。

英文:

Change:

&lt;link rel=&quot;sytlesheet&quot; type=&quot;text/css&quot; href=&quot;/Untitled/csss/style.css&quot;&gt;

to:

&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/Untitled/csss/style.css&quot;&gt;

you have stylesheet misspelled.

huangapple
  • 本文由 发表于 2023年3月4日 05:37:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632101.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定