0

Goals

  1. Make the carousel 60% x 60% of the size of the viewport.
  2. Make all images be the same size as the slideshow.
  3. Make the carousel fluid.

Does anyone know how to implement this? This seems to be a stubborn problem for me.

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
</head>

<body>

  <div id="history-slideshow" class="carousel slide" data-ride="carousel" data-interval="false">
    <div class="carousel-inner" role="listbox">
      <div class="carousel-item active">
        <img class="d-block w-100" src="https://d2z0k43lzfi12d.cloudfront.net/blog/vcdn215/wp-content/uploads/2017/06/15.06._Running-Stamina-1-800x510.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
      <div class="carousel-item">
        <img class="d-block w-100" src="https://www.shape.com/sites/shape.com/files/1200-woman-running-outside_1.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
      <div class="carousel-item">
        <img class="d-block w-100" src="/Virginian_banner.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
    </div>
    <a class="carousel-control-prev" href="#history-slideshow" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#history-slideshow" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </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.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
</body>

</html>

Thanks!!

srpalo
  • 493
  • 1
  • 5
  • 12

2 Answers2

0

change my color codes below to suit your needs

/*
Removes white gap between slides - change to base color of slide images
*/
.carousel {
  background:#F5F5F5; 
}

.carousel-item .img-fluid {
  width:60%;
  height: 60%;
}

/* 
anchors are inline so you need it make them block to go full width
*/
.carousel-item a {
  display: block;
  width:60%;
  height: 60%;
}

.carousel-control-prev {
  color:#036;
  margin-left: -.5rem;
  z-index: 10;
}

.carousel-control-next {
  color:#036;
  margin-right: -.5rem;
  z-index: 10;
}

.carousel-control-prev:hover {
  color:#0084FF;
}

.carousel-control-next:hover {
  color:#0084FF;
}

use this if you want to use fontawesome icons for the controls

<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<i class="fas fa-chevron-circle-left fa-2x"></i>

Previous

<a class="carousel-control-next text-faded" href="#carouselExampleControls" role="button" data-slide="next">
<i class="fas fa-chevron-circle-right fa-2x"></i>

Next

mlegg
  • 784
  • 6
  • 19
  • 35
  • close the controls with for each. I don't know why it's not showing in my code – mlegg Apr 30 '18 at 23:09
  • Unfortunately the slideshow makes up 100% x 100% of the viewport after using your implementation :/ – srpalo May 01 '18 at 01:31
  • take out the w-100 in the part where it says – mlegg May 01 '18 at 11:06
  • After removing w-100, the slidshow's dimensions were correct when the browser window is at full size. However, I need the slideshow to be fluid, and it's dimensions aren't getting smaller when I shrink the size of the viewport. – srpalo May 02 '18 at 18:51
0

In addition to the css rules below, I also made all images members of Bootstrap's .img-fluid.

html {
  height: 100%;
  width: 100%;
}

body {
  height: 100%;
  width: 100%;
  display: block;
}

.carousel {
  height: 60%;
  width: 60%;
}

.carousel-item {
  display: block;
  width: 100%;
  height: 100%;
}
<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
</head>

<body>

  <div id="history-slideshow" class="carousel slide" data-ride="carousel" data-interval="false">
    <div class="carousel-inner" role="listbox">
      <div class="carousel-item active">
        <img class="d-block img-fluid" src="https://d2z0k43lzfi12d.cloudfront.net/blog/vcdn215/wp-content/uploads/2017/06/15.06._Running-Stamina-1-800x510.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
      <div class="carousel-item">
        <img class="d-block img-fluid" src="https://www.shape.com/sites/shape.com/files/1200-woman-running-outside_1.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
      <div class="carousel-item">
        <img class="d-block img-fluid" src="/Virginian_banner.jpg">
        <div class="carousel-caption">
          <h3>HelloWorld</h3>
        </div>
      </div>
    </div>
    <a class="carousel-control-prev" href="#history-slideshow" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#history-slideshow" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </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.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
  
</body>

</html>
srpalo
  • 493
  • 1
  • 5
  • 12