Installing Bootstrap via NPM
Installing Bootstrap via NPM allows us to manage dependencies more efficiently and integrate Bootstrap into the project build process.
Here's how to install Bootstrap via NPM:
In the terminal we should run the following command:
After installing Bootstrap, we can include the Bootstrap CSS and JavaScript files in the HTML file or import them into the JavaScript files as needed;
For example, we can import Bootstrap's CSS and JS in the main HTML file (e.g.,
index.html
) using:
html9912345678910111213141516171819<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Bootstrap Example</title><!-- Include Bootstrap CSS --><linkrel="stylesheet"href="node_modules/bootstrap/dist/css/bootstrap.min.css"/></head><body><button class="btn btn-primary">Click me</button><!-- Include Bootstrap JS --><script src="node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script></body></html>
Note
In this course, we will utilize CDN links to integrate Bootstrap features into the project. This method eliminates the necessity of managing complex dependencies.
However, if you prefer working on your local machine using NPM, that's perfectly acceptable. Subsequent topics will function identically regardless of how you connect Bootstrap to your project.
Kiitos palautteestasi!
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme