我正在为一个朋友制作一个网页,这是我第一次使用bootstrap 4进行培训,同时还附带了一个教程,而且似乎可以完成所有工作,直到老师开始使用sass文件进行样式设置为止。我不知道为什么scss文件上的代码没有执行任何操作。
我从头开始跟踪了几次,以发现可能的不一致之处,但没有发现任何东西。可能与GitHub项目的过时版本有关吗?
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<title>As Maiores Duvidas</title>
</head>
<body id="home">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
<div class="container">
<a href="index.html" class="navbar-brand">As Maiores
Duvidas</a>
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a href="#home" class="nav-link">Home</a>
</li>
<li class="nav-item">
<a href="#home" class="nav-link">Sobre o Livro</a>
</li>
<li class="nav-item">
<a href="#home" class="nav-link">Sobre o Autor</a>
</li>
<li class="nav-item">
<a href="#home" class="nav-link">Compre o Livro</a>
</li>
<li class="nav-item">
<a href="#home" class="nav-link">Entre em contato</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- nav tag with a couple of classes sm creates the hamburget to show only in small screens-->
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
这是SCSS代码
$bg-color:red;
$font-color:#fff;
$primary-color:#008ed6;
body{
background:$bg-color;
color: $font-color;
}
.navbar {
border-bottom: $primary-color 3px solid;
opacity: 0.8;
}
package.json内容:
{
"name": "bs4starter",
"version": "1.0.0",
"description": "Bootstrap 4 starter workflow",
"main": "index.js",
"scripts": {
"start": "gulp"
},
"author": "Brad Traversy",
"license": "MIT",
"dependencies": {
"bootstrap": "^4.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"node-sass": "^4.12.0",
"popper.js": "^1.11.1"
},
"devDependencies": {
"browser-sync": "^2.18.13",
"gulp": "^3.9.1",
"gulp-sass": "^3.1.0"
}
}
答案 0 :(得分:0)
您可能没有将SCSS文件编译成CSS。我看到您的package.json文件中有node-sass。您可以运行
node-sass src/style.scss dest/style.css
或将其添加到启动脚本中,以使其在每次启动服务器时运行。但我不建议您这样做,因为您并不总是修改此文件,它会增加启动时间