Encountering an issue with importing bootstrap.css; the file "bootstrap.css" cannot be accessed as the resource is unavailable

As I venture into the world of web design, I've decided to dive deep into learning Flask. The foundation of my web application has been laid out and now it's time to add some style.

I recently obtained the compiled CSS and JS files from Bootstrap, and I'm eager to integrate them into my customized SCSS file so that I can utilize and build upon its features using @extend. Here is a snippet of my test code:

@import 'C:/Users/lili_/Desktop/bootstrap-4.3.1-dist/css/bootstrap.css';
$navbar_color: red;
.my_navbar {
    @extend .navbar;
    background-color: $navbar_color;
}

The issue arises when I attempt to run sass and convert this into a CSS file - an error message stating:

"The selector ".navbar" was not found."

This same error persists regardless of which .class or #id I try to @extend. Furthermore, when I navigate to the "bootstrap.css" file within its folder, everything appears normal. However, if I follow the @import link (which I've copied into my test.scss) from Visual Studio Code editor, an error window pops up with the message:

"Unable to open 'bootstrap.css'
resource not available"

Answer №1

It seems like there may be some confusion in your approach. For example, attempting to @import a CSS file into a SCSS (SASS) file can lead to issues. There are a couple of ways you can tackle this situation.

One option is to directly link the bootstrap CSS file within the \head section of every HTML file, as outlined in the official documentation. Following that, you can customize the styles by linking your CSS file and overriding specific properties.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

Another approach would involve incorporating an npm package that provides Bootstrap partials in SCSS format which can be imported into your main SCSS file seamlessly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In Internet Explorer, the Jquery Datatable within a Bootstrap d-flex container is exceeding its parent's boundaries

When using the d-flex class, Datatable renders outside or overflows from the parent element specifically in Internet Explorer. <div class="d-flex justify-content-center"> <div class="card"> <div class="card-header">HEADER< ...

How to override the styling of a parent element in CSS

I'm encountering an issue with my website's sidebar. I've set the background color to yellow for elements with the currentPage class. This works fine for the 'Home' tab, but when I try to do the same for a nested tab like 'tag ...

Add fresh inline designs to a React high-order component creation

Applying a common HOC pattern like this can be quite effective. However, there are instances where you may not want a component to be wrapped, but rather just extended. This is the challenge I am facing here. Wrapper HOC const flexboxContainerStyles = { ...

Animating vector graphics from a circle to a line using SVG

Is it possible to convert a circle into a line (path)? I'm having trouble finding information on how to shape the svg element. Perhaps my search technique is the issue. <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg ...

Adjust the size of the text and save it in a cookie for later use

I am in need of a script that can dynamically increase and decrease the font size on a website while retaining the user's chosen setting even after they return to the site. I believe utilizing cookies is the way to achieve this functionality. Despite ...

Adjust the width of an anchor tag

I have been experimenting with different solutions and unfortunately, I have not been successful in resolving the issue at hand. While working on a WordPress website, I encountered some challenges. Despite having some knowledge in this area, I am struggli ...

Issue with displaying jQuery 3.5.1 mobile CSS formatting on live server preview using Visual Studio Code

Despite my best efforts, I can't seem to make the jQuery CSS stylesheet work properly. I've been using the live preview extension in VSCode and got the CSS directly from the jQuery website. <!DOCTYPE html> <html> <head> < ...

Click a button to adjust the height of an element

My webpage features a dashboard with tabs on the left and corresponding content on the right. To ensure proper alignment, I have utilized Bootstrap to create two columns - one for the tabs and one for the content. However, I am facing an issue where the bo ...

Creating a line break in HTML using Bootstrap

Reference the source provided, specifically the red alert option. Here is an example: <div class="alert alert-dismissible alert-danger"> <button type="button" class="close" data-dismiss="alert">&times;</button> <strong> ...

Creating personalized widths for bootstrap classes with SASS

I am interested in enhancing the bootstrap source code by creating additional w-XX classes. Specifically, I aim to include both w-40 and w-60. According to the documentation, modifying the $sizes variable is necessary for this customization. In my custom. ...

what distinguishes CSS properties for Id versus class selectors

Currently in the process of creating my inaugural website, which consists of just four pages. Each page follows the standard layout structure with a header, navigation bar, content division (div id="content"), and footer. As I delve into adding CSS proper ...

A centered Bootstrap navigation bar on a WordPress site

My Bootstrap navbar is floating in the center on WordPress and I'm not sure why. Can anyone help me with this issue? Could it be related to WordPress or my stylesheet problems? (Will update my code here if you need) https://i.sstatic.net/vxVv4.jpg ST ...

Achieve this effect by making sure that when a user scrolls on their browser, 50% of the content is entered into view and the remaining 50%

Is there a way to achieve this effect? Specifically, when the user scrolls in the browser, 50% of the content is displayed at the top and the other 50% is shown at the bottom. ...

When a user clicks on the product id field, I would like to add my data underneath the table and then conduct a search

When adding data to a table, I noticed that it is being added at the top instead of below the table, I implemented a search feature where the user can enter a product id, but I cannot seem to locate the error in my code, Is there a way to add a search fiel ...

Are programmatic clicks distinguishable from manual clicks in JQuery?

Currently, I am in the process of creating selectable and draggable elements for a table. You can test the functionality by following this JsFiddle link (please try vertically selecting). Initially, the selection works well but upon trying to select for th ...

Creating a horizontal split on a page using Bootstrap to achieve two equal sections

Does anyone know how to split a page into two horizontal halves using Bootstrap 4? I am trying to create two forms on one page but struggling with the layout. I attempted using this code, but it doesn't seem to be working: page.html <div class=" ...

Leveraging universal SCSS variables within an AstroJS endeavor

Hello, I'm a beginner when it comes to using AstroJS. In my project structure, there is a folder named styles inside the src folder. Inside this folder, there is a file called global.scss where I have defined some global SCSS variables in HEX format: ...

What is the method for importing .scss files throughout a Next.js application?

I'm looking to transform my React app into a Next.js app. In the current React setup, I have .scss CSS files being imported in various components. However, once I transfer the code to a Next.js environment, I encounter an error: Global CSS cannot be ...

Having Difficulty Formatting HTML Input in Next.js

I'm encountering difficulties when trying to style HTML form elements in Next.js. I've been unsuccessful in applying CSS using a simple class name from the imported stylesheet, but have managed to achieve some success with inline styling by using ...

JQuery Mobile header style vanishing when applied to a page generated dynamically

My second page retrieves data from an Ajax call on the home page, but the header lacks JQuery styling and I suspect a connection between the two. Here is the HTML for the dynamically generated page: <div data-role="page" id="breakdownDialog" data-add-b ...