CDN is causing the carousel and header issue

Hi,
I am learning web development out of my passion, I am stuck at bootstrap Carousel. I am able to do proper root cause analysis. I found out that below CDN is causing the issue. If I remove it, my header looks perfect, but the Carousel images come one below the other. If I leave it on, the header unordered lists start from the center of the header but the carousel works. Here is my complete code Below that it the CDN.


<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap.css">>
  <link rel="stylesheet" href="bootstrap.min.css">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
  <style>

  .navbar{
    background-color: black;
    font-size: 20px;
    padding-top: 10px;
    margin: 0;
    margin-top: -20px;
    margin-left: -5px;
    margin-bottom: -5px;
  }
  .navbar-brand{
    float: left;
  }
  .form-control{
    border-radius: 10px;
    margin-top: 9px;
    width: 250px;
  }
.navbar-brand{
  font-size: 30px;
}
.carousel-inner img {
width: 100%;
height: 100%;
margin-bottom: 50px;
}
.box{
  border: 30px solid white;
  background: orange;
  height: 300px;
  width: 300px;
  margin:auto;
}
#recent1{
  text-align: center;
}
#best1{
  text-align: center;
}
.col-lg-3{
  text-align: center;
}
.carousel-inner{
  width: 100%;
  height: 100%;
}
</style>
</head>
<body>



  <nav class="navbar navbar-default">
                  <div class="navbar-header">
                        <a href="#" class=navbar-brand>SP</a>
                  </div>
                  <ul class="nav navbar-nav">
                      <li id="Telugu"><a href="#">  Telugu Movies  </a></li>
                      <li id="Hindi"><a href="#">  Hindi Movies  </a></li>
                      <li id="English"><a href="#">  English Movies  </a></li>
                  </ul>
                  <ul class="nav navbar-nav navbar-right">
                      <li><input class="form-control" type="text" placeholder="Search" aria-label="Search"></li>
                      <li><a href="file:///C:/Users/spali/OneDrive/Documents/new%20laptop/HTML_Learn/BootStrap/website/ContactUs.html">  Contact Us  </a></li>
                  </ul>
  </nav>

  <div class="container">
  <div id="demo" class="carousel slide" data-ride="carousel" data-interval="3000">

  <ul class="carousel-indicators">
    <li data-target="#demo" data-slide-to="0" class="active"></li>
    <li data-target="#demo" data-slide-to="1"></li>
    <li data-target="#demo" data-slide-to="2"></li>
  </ul>

  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="TeluguMovies.JPG" alt="TeluguMovies" width="1100" height="300">
    </div>
    <div class="carousel-item">
      <img src="HindiMovies.jpg" alt="HindiMovies" width="1100" height="500">
    </div>
    <div class="carousel-item">
      <img src="EnglishMovies.jpg" alt="EnglishMovies" width="1100" height="500">
    </div>
  </div>

  <a class="carousel-control-prev" href="#demo" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#demo" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
</div>

<div class="container">
<h1 id="recent1">Recently Added</h1>
<div class="row" >
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 1</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 2</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 3</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 3</div>
</div>
</div>



<div class="container">
<h1 id="recent1">Recently Added</h1>
<div class="row" >
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 1</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 2</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 3</div>
  <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 box">Element - 3</div>
</div>
</div>
</body>
</html>

CDN below is causing the issue. Please let me know if there is an alternate thing I can do. I am using bootstrap.css v3.4.1


  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">

Hey there,

it would be awesome to see your code in action,
e.g. as a project on codepen:

You can simply add an index.html to the Project Root-section and put your code there.

Looking forward to seeing it!

1 Like