r/csshelp • • Nov 20 '20

Bootstrap spinners not working

Hi all,

I'm learning bootstrap, and have copied the most basic code for a spinner from their documentation:

inside the <head> tag I import dependencies:

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

<script src="js/bootstrap.min.js"></script>

<link rel="stylesheet" href="css/bootstrap.min.css">

and in the <body> tag I implement the spinner:

<div class="spinner-border" role="status"

<span class="sr-only"></span>

</div>

And I'm greeted only with a blank screen. I have no idea why this is happening, as other modules are working fine ( carousel, drop-down menus, etc.). I'm sure the framework files I'm importing are directing to the correct path, and the browser logs show no errors.

Help me please ;(

EDIT: Figured it out, I was using an old version of bootstrap (I know, I'm a noob). Was using 3.something whereas I now use 4.5.3 and it works .

6 Upvotes

3 comments sorted by

1

u/FriesWithThat Nov 20 '20

Could it perhaps be working, but just so fast because of your light local page load that you don't see it? Try dev tools > network > online and give it some throttling.

1

u/Tagina_Vickler Nov 20 '20 edited Nov 20 '20

That doesn't seem to do anything either :/

EDIT: Figured it out, I'm a noob. Thanks for taking the time to reply :)

1

u/FriesWithThat Nov 20 '20 edited Nov 20 '20

Well, I don't use bootstrap very often, but I was able to get the animation to work just launching a quick webpage in Liveserver (extension of VSCode):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
  <link rel="stylesheet" href="your-styles.css">
  <title>Document</title>
</head>
<body>
  <div class="spinner-border" role="status">
    <span class="sr-only">Loading...</span>
  </div>

<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script> -->
<!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/ -->
</body>
</html>

I commented out the scripts you wouldn't need for this functionality, but left them there for placements. Replacing the spinner with actual content will, of course, take a little JS to toggle that class on and off. Hope that helps.

*You can try different ways of loading bootstrap, the cdn (as I used) can be a lot less problematic than working with the downloaded package.