html - css 文件不能与 html 文件一起使用(即使 css 文件已与 html 文件链接)?
问题描述
我是 css 的新手,并试图编写一个 css 文件以在 html 文件中使用,这是我的想法。
首先,我写了一个这样的html文件
<!DOCTYPE html>
<html>
<!-- phan dau -->
<head>
<title>
ok we will make it
</title>
</head>
<!-- phan than -->
<body>
<div>
<h1 id="first-heading">css selector</h1>
<h1 class="css selector">css selector</h1>
<h1 class="css selector">css selector</h1>
</div>
</body>
然后,我写了一个这样的css文件
#first-heading {
color: red;
}
我的想法是,使用 css 文件,首先使用第一个 css 选择器使其变为红色。但它并没有像我希望的那样是红色的。两个文件在同一个文件夹中。
你能给我一些关于这个问题的想法吗?非常感谢您的宝贵时间。
解决方案
你给你的内部css写如下
<head>
<style>
#first-heading {
color: red;
}
</style>
</head>
您是外部 css 正确提供两个文件的链接。但是您调用的外部 css 会提供您的链接
<link rel="stylesheet" href="./style.css">
谢谢
推荐阅读
- gmail - 无法连接到使用 2FA 保护的 Gmail SMTP
- firebase - Firebase 为上次更改添加时间戳的函数多次运行
- codenameone - 如何使用 cn1 文件选择器选择多个图像
- command-line - Atom platformio 不会运行 python
- phpmyadmin - phpmyadmin 卡在处理请求上
- java - 在执行阶段设置的 Android Test Instrumentation Runner 参数
- python - 将字符串“02-04-20189.45”转换为熊猫数据框中的日期时间类型
- django - 在 Django 上将用户从数据库迁移到另一个数据库
- python-3.x - 使用 Chrome 问题的 Python 3 中的多处理 selenium
- url - 在 Laravel 5.6 中,如何创建相对链接?