Having trouble replacing bootstrap with external CSS

As a beginner in a coding bootcamp, I have been introduced to the world of bootstrap. While some of my friends shy away from using it for various reasons, I have no choice but to learn it in class. I've experimented with different techniques to style elements, such as adding new classes and being more specific in my CSS selectors, all followed by the !important declaration. However, I'm starting to suspect that my external stylesheet may not be linked properly despite checking multiple times and making adjustments. Unable to get help from my friends who are busy working, I'm turning to the community for assistance!

Here is a snippet of my HTML and CSS code for your review. The CSS may seem basic as it's for testing purposes to figure out how to override the HTML styles. Your time and insight are greatly appreciated.

On a side note, my classmates poke fun at my coding spacing habits. If you think this could be a problem, please feel free to share your thoughts! I'm open to feedback and eager to refine my coding practices before they become ingrained.

.jumbotron h1
{
    background-image: url(/img/pizza.png) !important;
}
title
{
    font-family: cursive !important;
}
<!DOCTYPE html>
<html 
    lang="en"
>
<head>
<link 
    rel="stylesheet" 
    href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
    integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
    crossorigin="anonymous"
>
<link 
    rel="stylesheet"
    type="text/css"
    href="/css/custom.css"
>

<meta 
    charset="UTF-8"
>
<meta 
    name="viewport" 
    content="width=, initial-scale=1.0"
>
<meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge"
>
<title>
    Pizza World
</title>
</head>
<body>
<nav 
    class="navbar navbar-expand-lg navbar-light bg-light"
>
    <a 
        class="navbar-brand" 
        href="#"
    >
        Pizza World
    </a>
    <button 
        class="navbar-toggler" 
        type="button" 
        data-toggle="collapse" 
        data-target="#navbarSupportedContent" 
        aria-controls="navbarSupportedContent" 
        aria-expanded="false" 
        aria-label="Toggle navigation"
    >
    <span 
        class="navbar-toggler-icon"
    >
    </span>
    </button>
<div 
        class="collapse navbar-collapse" 
        id="navbarSupportedContent"
>
    <ul 
        class="navbar-nav mr-auto"
    >
        <li 
            class="nav-item active"
        >
        <a 
            class="nav-link" 
            href="#"
        >
            Order Online 
        <span 
            class="sr-only"
        >
            (current)
        </span>
        </a>
        </li>
        <li 
            class="nav-item"
        >
        <a 
            class="nav-link" 
            href="#"
        >
            Menu
        </a>
        </li>
<form 
    class="form-inline my-2 my-lg-0"
>
    <input 
        class="form-control mr-sm-2" 
        type="search" 
        placeholder="Zip Code" 
        aria-label="Zip Code"
    >
    <button 
        class="btn btn-outline-success my-2 my-sm-0" 
        type="submit"
    >
        Search stores near you!
    </button>
</form>
</div>
</nav>
<div 
    class="jumbotron"
>
        <h1 
            class="display-12 myh1class"
        >
            Hello, world!
        </h1>
        <p 
            class="lead"
        >
            This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
        </p>
        <hr 
            class="my-4"
        >
        <p>
                It uses utility classes for typography and spacing to space content out within the larger container.
        </p>
        <p 
        class="lead"
        >
          <a 
            class="btn btn-primary btn-lg" 
            href="#" 
            role="button"
        >
            Learn more
        </a>
        </p>
      </div>
<script             
    src="https://code.jquery.com/jquery-3.2.1.slim.min.js" i
    ntegrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
    crossorigin="anonymous"
>
</script>
<script 
    src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
    integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
    crossorigin="anonymous"
>
</script>
<script 
    src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
    integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
    crossorigin="anonymous"
>
</script>

    
</body>
</html>

Answer №1

There are various methods available to customize and override the default Bootstrap CSS styles.

  1. One approach is to use the !important declaration, although this method may lead to unintended consequences in the future.

  2. Another option is to download the Bootstrap JS and CSS files, make necessary modifications, and then include them directly in your project files instead of using a CDN link.

  3. You can also utilize a CSS selector like id="bootstrap-override" in your HTML. Bootstrap primarily relies on classes, which hold less weight than IDs. For more information on CSS specificity, check out this helpful article here.

Answer №2

To easily incorporate CSS into your project, consider linking an external Bootstrap stylesheet to your HTML files. This allows for simple editing and customization, making the process very straightforward.

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

Button Hover Effect: Transition with Style

I am trying to implement a one-second transition from the default color scheme to the hover color for a Button element in Material UI. I am using the transitions.create(props, options) method as described in this article: https://medium.com/@octaviocoria/c ...

Implementing a blur effect on a CSS loader

I have successfully implemented a loader feature where a loading animation is displayed upon clicking the submit button, indicating that the form submission is in progress. However, I am encountering an issue when trying to apply a blur effect to the entir ...

What is the best way to refresh a webpage in Vue.js following a specific event or a button click?

Is there a way to reload a webpage only once after clicking a button, without the need for auto-refreshing at set intervals? I've written my code in Vue.js. Can anyone offer guidance on how to accomplish this? Any assistance would be greatly apprecia ...

Navigating to a new page by clicking a button

I am trying to redirect to a different web page when a button is clicked. Below is the code snippet I am working with: JavaScript code snippet: app.controller('myCtrl', ['$scope', '$location', function($scope, $location) { ...

Loading images in advance with AJAX for enhanced AJAX performance

My website is structured in a sequential manner, where page1.html leads to page2.html and so on. I am looking to preload some images from the third page onto the second page. After searching, I came across this amazing code snippet: $.ajax({ url ...

Attempting to extract only the text content from a specific div using XPath

I am currently facing a challenge in writing a script to extract the title element from a poorly coded webpage. The developer who created this website did not use any classes, only div elements. Below is a snippet of the source code I am trying to scrape: ...

Guide on including the sequential images within the previous and next button of a carousel

Currently working on my portfolio website, I have managed to code a carousel for displaying my images. The only challenge I am facing now is how to make the 'Next' and 'Prev' buttons show the next and previous images respectively. Does ...

Enabling a checkbox grid for exclusive rectangular selections

Apologies for the confusing title, I struggled to come up with something more fitting. Let's say my client needs a square area on their homepage where they can upload images that will be placed within various boxes in a grid. The available box optio ...

How to Customize Button Background Color in Bootstrap 5 Navbars

I tried to adjust the background color of a button within a bootstrap navbar, but I couldn't get it to change completely. How can I fix this issue? See below for the code snippet: <div class="container-fluid"> <nav class=" ...

Perfecting the Radio Button Selection (because why not?)

Struggling to round the outer corners of three inline squared radio buttons with unique IDs. Need help fixing my CSS syntax - I can get each button to individually round its corners, but not just radio1 and radio3's outer corners. Check out the issue ...

What could be causing the lack of animation in W3schools icons?

I've followed the steps provided and even attempted to copy and paste them. However, I'm experiencing an issue where the animation doesn't fully execute. Instead of the bars turning into an X shape, they reset halfway through the animation. ...

Ways to center a spinner on the screen using CSS during loading

Upon loading the page, my spinner appears in the center of the screen after a second. However, in the initial frame of the page, it is not centered but positioned on the top-left corner instead. How can I ensure that my spinner starts off centered from the ...

The Perfect Scrollbar feature is not functioning properly in conjunction with the accordion menu

I am having some trouble with implementing the Perfect Scrollbar alongside an accordion slider menu. The scrollbar is not working as expected, and you can view the fiddle here. On initial page load, the scrollbar only appears for the first sub-menu aft ...

Switching over to styled components from plain CSS using a ternary operator

Currently, I am in the process of converting my project from using regular CSS to styled components (https://styled-components.com/). So far, I have successfully converted all my other components except for one that I'm having trouble with. I've ...

What could be causing the border-collapse property to be ineffective on my HTML table?

My HTML table has nested tables, but the border collapse property is not working. Despite adding the border-collapse property to both the main table and nested tables, only the outer borders are visible, with no inside borders. <table style="bord ...

Using jQuery, you can disable an option upon selection and also change its border color

learn HTML code <select name="register-month" id="register-month"> <option value="00">Month</option> <option value="01">January</option> <option value="02">February</option> <option value="03"& ...

"Problem with the Hide/Show Load feature: it's not functioning

After a user submits a form, my script shows 2 divs and hides 1 div. The form's target is an Iframe on the same page. I am looking to delay the Hide/Show events until the Iframe loads. I was successful in accomplishing this with a loading animation, ...

Creating a unique data attribute in Alpine.js - A step-by-step guide

I am looking to establish a custom attribute and modify the value when clicked. This is my current setup: <div x-data="{ colorred = true }"> <div @click="colorred = !colorred">set red state</div> </div> I ...

Adjusting button alignment when resizing the browser

Is there a method to relocate buttons using Bootstrap 5 in HTML or CSS when the browser is resized? For instance, if the button is centered on a full-screen browser, but I want it at the bottom when resized. Is this achievable? ...

Use the no-repeat feature to set the background image in an Asp:Chart

I have been working with the asp:Chart control and have found that its BackImage property functions well. However, I have encountered two issues while trying to set the background image. I am unable to successfully set the no-repeat property of the Bac ...