What could be the reason for my application not utilizing its bootstrap classes effectively?

Just starting out with Bootstrap and have made some progress. However, the bootstrap classes I'm using are not rendering properly. What could be the issue?

<div class="position-absolute bottom-0 end-0 border border-dark">

https://i.sstatic.net/VTlQQ.png

Interestingly, when I use regular CSS styling, everything works as expected.

<div style="position:absolute; bottom: 0; right: 0; border-style: solid;">

https://i.sstatic.net/mWQfT.png Check out the complete HTML code snippet below:

<!DOCTYPE html>
<html>
    <head>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> 

    <title>{{ title }}</title>
    </head>
    <body>
        <div id="background-div" class="position-relative mx-10">
            <div id="title-div">
                <h1>Title</h1>
                <h3>One-liner goes here</h3>
                <hr>
            </div>
            <div id="content-div" style="max-width: 66%;">
                <div class="row">
                    {% block content %}
                    {% endblock %}
                </div>
            </div>
            <div class="position-absolute bottom-0 end-0 border border-dark">
                <div id="legend-div">
                    legend goes here
                </div>
                <div id="scale-bar-div">
                    scalebar goes here
                </div>
            </div>
        </div>
    </body>
</html>

Answer №1

When working with Flask, if you are displaying HTML templates side by side (by running the Flask application), you may need to do a hard refresh by pressing Ctrl+Shift+R (Windows) because changes in HTML or CSS may not take effect immediately even after a simple refresh!

Alternatively, you can inspect your HTML page using the developer's tool. Opening the developer's tool: Ctrl+Shift+J or Right click<inspect page This allows you to check which CSS styles have been applied.

Answer №2

Eureka! I finally figured it out! The issue was with the CDN I was using. Just for your information, I had originally found the CDN on W3Schools (link).

Here is the correct CDN that should be used:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

Although this won't necessarily resolve the issue with the bootstrap styling (since classes and style attributes may not produce identical results), it does address the main problem of bootstrap not functioning correctly.

Answer №3

If you're new to Bootstrap, it's recommended to begin with the latest version available. While v5 is currently in Beta stage, it is proving to be stable and reliable. You can find more information at https://getbootstrap.com/

Keep in mind that if you are still using an older version of Bootstrap in your project, consider starting with v4. You can access the documentation for v4 at https://getbootstrap.com/docs/4.6/getting-started/introduction/

It's important to note that there have been numerous bug fixes and improvements from version 4.0 to 4.6.

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

Why can't we use percentages to change the max-height property in JavaScript?

I am currently working on creating a responsive menu featuring a hamburger icon. My goal is to have the menu list slide in and out without using jQuery, but instead relying purely on JavaScript. HTML : <div id="animation"> </div> <button ...

Guide to retrieving the primary key auto-increment value for the ID field in an SQL record using PHP Scripting

I am currently working on a multi-page web survey form and I have a PHP script called process.php that handles my responses on www.buythosecars.com. This script stores the responses in a MySQL table and then redirects the user to www.buythosecars.com/surve ...

Three fixed position divs arranged horizontally side by side

I am attempting to organize 3 divs in a row using Flex. ISSUE 1: The div that is centered is set with position: fixed. However, the two other divs on each side do not stay aligned with the centered fixed div when scrolling. If I change the centered div to ...

What is the best way to change the height of cells within a grid layout?

Enhancing the buttons with a touch of depth using box-shadow resulted in an unexpected outcome - the shadows bleeding through the gaps and causing uneven spacing. https://i.sstatic.net/LYssE.png In an attempt to rectify this issue, I decided to tweak the ...

Spacing Issue with Material UI Gap Placement

Currently, I am implementing Material UI 5 within a React project using the following code snippet: <Stack> <Stack flexDirection="row" justifyContent="center" padding={4} spacing={{ xs: 4 }} ...

Elements not following percentage in top positioning

I am facing an issue with resizing containers on my webpage. Despite using position: relative for everything, I am unable to properly adjust the size of the top containers using percentages. Any assistance would be greatly appreciated! ...

How do I prevent a media query written for small screens from also affecting large screens?

@media only screen and (min-width: 320px), (min-width: 360px), (min-width: 375px), (min-width: 600px){ CSS properties for various screen widths are defined here } ...

Create a choppy distortion effect using CSS filters in Google Chrome

Currently working on a hover effect that enhances image brightness and scales the image during hover. However, I am experiencing some choppiness in the transform animation due to the CSS filter. It's strange because it appears to be smooth in Safari a ...

Is it possible to align text to an image within an input text field?

<input type="text" class="usernm" style="color:black;font-weight: bold;outline-width: 0;" id="username" /> I have a question about styling HTML. I am attempting to include an icon inside a text field, but I'm strugglin ...

Display only the initial word in a hidden input value of an HTML document using NodeJS Express

I have a Node.js application that utilizes EJS as its template engine. On multiple pages, I incorporate hidden inputs and retrieve their values using req.body. Although my body parser in Express is configured correctly, I've noticed an issue where hid ...

Incorporating custom CSS and HTML into the link is essential for enhancing the appearance of KnpMenu

I'm working with the KnpMenuBundle and I need to customize a link that has the route 'uri'=>'#'. How can I achieve this? The desired link should be styled like this: <a href="#" class="js-sub-menu-toggle"> &l ...

Vue 3 has officially deprecated the use of ::v-deep as a combinator. Going forward, please utilize ::v-deep(<inner-selector>) instead

Recently, an error message has been popping up in Vue 3 regarding the use of ::v-deep. The warning states that using ::v-deep as a combinator is deprecated. Instead, it recommends using ::v-deep(<inner-selector>) Here is an example of the CSS ...

How can you hide a column in Bootstrap 5 if it has no content?

Is there a way to collapse my two column div vertically so that if the second column is empty, the third column can expand to occupy the space? <div class="row"> <div class="col">first col</div> <div class=&qu ...

Transmit data from the Windows Communication Foundation to JavaScript

Looking to invoke the WCF service through JavaScript, utilizing AJAX? Check out this resource: Calling WCF Services using jQuery Here's my query: Is there a method to retain some JavaScript-related data after making a request, and then transmit inf ...

Is it advisable to set the html root at 62.5% when using rem units in CSS? Does this imply that the default font size of browsers is 16px?

During a discussion with a group, I mentioned the 62.5% trick for scalability (setting 62.5% as font size in root and using rem units throughout CSS for easier scalability when users change default browser font size) and their arguments were as follows: " ...

Using a border-radius on Internet Explorer 11 reveals the background through the corners

Encountering issues with rounded borders in IE 11 (11.0.9600.18350)? Check out this minimal fiddle for more information: https://jsfiddle.net/7phqrack/2/ Here's the HTML code snippet: <div class="backgrounddiv"> <div class="outer"> ...

Tips for employing 'live CSS' in Rails

As someone who is new to Ruby on Rails, I am currently facing a challenge. I want to extract data from specific fields in my database and utilize them for styling purposes. For instance, within my 'Student' database, there are height and width f ...

Conceal all components on a webpage with the exception of a designated div

I am looking to selectively hide elements on the page, revealing only the contents of div.k1. The page contains numerous elements. How can I achieve this using just CSS? <div>1-this will be hidden</div> <div class="k1"> 2-this div wi ...

Using XSL variables in JavaScript code

I've noticed that there have been similar questions asked, but none of the solutions seem to help in my case. So, I have this variable named 'var': <xsl:variable name="var"> val </xsl:variable> Now, I want to use it like thi ...

Issue with overflow:scroll displaying incomplete div contents

I am attempting to create a sidebar with a fixed position, featuring a small header and a scrollable content area below it. The issue I am facing is that I am unable to scroll through the entire content within the div, resulting in some parts being cut of ...