Container slide-show fill error

I'm attempting to create a slide show with an overlapping caption that appears when hovering over the container or image. The image needs to fit exactly inside the container so no scroll bar is shown and the border radius is correct. I managed to achieve this, but there's a bug. When the page loads initially, there is flickering and sometimes the scroll bar appears, or vice versa. Is there a way to fix this issue?

https://i.stack.imgur.com/aggyt.jpg

https://i.stack.imgur.com/fRa3q.jpg

https://i.stack.imgur.com/uumKD.jpg

I have tested in both Chrome and Firefox, and they exhibit the same incorrect behavior.

var slideIndex = 1;
showSlides(slideIndex);

// Next/previous controls
function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("slide");
  var dots = document.getElementsByClassName("dot");

  if (n > slides.length) {
    slideIndex = 1
  } else if (n < 1) {
    slideIndex = slides.length
  }

  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
    dots[i].className = dots[i].className.replace(" active", "");
  }

  slides[slideIndex - 1].style.display = "block";
  dots[slideIndex - 1].className += " active";
}
@charset "UTF-8";
* {
  margin: 0px;
  padding: 0px;
}

#header {
  background-color: #202020;
  height: 120px;
  overflow: auto;
}

body {
  background-color: #f5f5f5;
}

.navbar li {
  display: inline;
  margin-left: 50px;
}

.navbar {
  font-family: "Roboto Thin";
  font-size: 20pt;
  color: white;
  list-style-type: none;
  padding-top: 48px;
  margin-left: 400px;
}

#login {
  font-size: 14pt;
  color: white;
  float: right;
  padding-top: 57px;
  padding-right: 35px;
}

#login li {
  display: inline;
  margin-left: 10px;
}

.titulo {
  font-family: "Roboto Light";
  font-size: 45pt;
}

img#mds-modern {
  float: left;
  padding-top: 15px;
  height: 100px;
}

img#mds-logo {
  float: left;
  height: 120px;
}

div.body {
  padding-top: 20px;
}

.carousel-container {
  max-width: 773px;
  max-height: 509px;
  border-radius: 10px;
  position: relative;
  margin: auto;
  overflow: auto;
}

.slide {
  display: none;
}

.slide img {
  width: 100%;
  height: 100%;
}

.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  margin-top: -22px;
  padding: 16px;
  color: white;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.caption {
  height: 50px;
  color: rgba(242, 242, 242, 0);
  font-size: 20pt;
  font-family: "Roboto Thin";
  padding-top: 12.5px;
  position: absolute;
  bottom: 0px;
  width: 100%;
  text-align: center;
}

.carousel-container:hover .caption {
  background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(25, 25, 25, 0.8));
  color: #f2f2f2;
  transition: background 2s;
}

.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active,
.dot:hover {
  background-color: #717171;
}

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

.row::after {
  content: "";
  display: table;
  clear: both;
}

.column {
  float: left;
  width: 33.33%;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}
<!DOCTYPE html>
<html>

...

Answer №1

After some experimentation, I've found a solution. Instead of adding border-radius to the parent carousel-container, I have applied it to both the caption and the images within. Additionally, I made the decision to remove the overflow property from the parent element.

@charset "UTF-8";
* {
  margin: 0px;
  padding: 0px;
}

/* Styles for Header */
#header {
  background-color: #202020;
  height: 120px;
  overflow: auto;
}
body {
  background-color: #f5f5f5;
}
.navbar li {
  display: inline;
  margin-left: 50px;
}
.navbar {
  font-family: "Roboto Thin";
  font-size: 20pt;
  color: white;
  list-style-type: none;
  padding-top: 48px;
  margin-left: 400px;
}
#login {
  font-size: 14pt;
  color: white;
  float: right;
  padding-top: 57px;
  padding-right: 35px;
}
#login li {
  display: inline;
  margin-left: 10px;
}
.titulo {
  font-family: "Roboto Light";
  font-size: 45pt;
}
img#mds-modern {
  float: left;
  padding-top: 15px;
  height: 100px;
}
img#mds-logo {
  float: left;
  height: 120px;
}

/* Styles for Body */
div.body {
  padding-top: 20px;
}
.carousel-container {
  max-width: 773px;
  max-height: 509px;
  position: relative;
  margin: auto;
}
.slide {
  display: none;
}
.slide img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
} 

/* Carousel Controls */
.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  margin-top: -22px;
  padding: 16px;
   color:white;
   ...

...

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

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

Pinia has not been instantiated yet due to an incorrect sequence of JavaScript file execution within Vue.js

I'm currently developing a Vue.js application using Vite, and I have a Pinia store that I want to monitor. Below is the content of my store.js file: import { defineStore } from 'pinia'; const useStore = defineStore('store', { st ...

using async.waterfall with async.apply

Here is a code snippet that I am working with: async.waterfall([ // Read directory async.apply(fs.readdir, '../testdata'), // Load data from each file function(files, callback) { async.each(files, loadDataFromFile, callback); } ], ...

What is the best way to show input choices once an option has been chosen from the 'select class' dropdown menu?

When it comes to displaying different options based on user selection, the following HTML code is what I've been using: <select class="form-control input-lg" style="text-align:center"> <option value="type">-- Select a Type --</opti ...

Implementing jQuery form validation including checking for the strength of the password

My understanding of jQuery was quite basic until I began working on jQuery form validation with password strength check. I successfully completed the password strength check portion, but now I am unsure of how to enable the submit button once the condition ...

Unable to use addEventListener on media queries exceeding 768px

When testing the site on Firefox 49 and Chrome 63, I encountered the same issue. Clicking on each card worked fine on iPhone4, Galaxy 5, and iPhone 8 using Chrome. However, after switching orientations from 640px to 320px portrait view, the top card would ...

Discover the steps to integrating jsfiddle into my local development environment

If you want to check out the code for this example, head over to jsfiddle at this link. And below is a snippet of the HTML file: <!DOCTYPE html> <html> <head> <script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js" type= ...

Creating a horizontal scroll effect using jQuery when the widths of the items are not

I am working on a jQuery gallery that showcases images in a horizontal layout. Below the images, there are "left" and "right" buttons which allow users to scroll through the pictures. There are many tutorials and plugins available for this type of function ...

What is the correct way to assign a property to a function's scope?

Lately, I've been delving into Typescript Decorators to address a specific issue in my application. Using a JS bridge to communicate TS code between Android and iOS, we currently define functions as follows: index.js import foo from './bar' ...

Using Angular to pass an index to a pipe function

Currently, I am attempting to incorporate the *ngFor index into my pipe in the following manner: <td *ngFor="let course of courses | matchesTime:time | matchesWeekday:i ; index as i">{{course.courseName}}</td> This is how my pipe is structure ...

Optimizing performance: Making the most of mongoose updateMany middleware

PROBLEM SOLVED: SOLUTION PROVIDED BELOW I have a piece of code where I am updating elements one by one: //registerCustomers.js const CustomerRegistrationCode = require("../models/CustomerRegistrationCode"); const setRegCodesToUsed = async (regC ...

Ensure that the HTML input element only accepts positive values, including decimal numbers

I need to build an input field that only accepts positive numbers, including decimal values. Leading zeros are not allowed, and users should not be able to paste invalid values like -14.5 into the field. Here is my current implementation: <input type= ...

The attribute 'subtle' is not found within the definition of 'webcrypto' type

Currently, I am working with Node v17.4 and I am looking to utilize the webcrypto API. Referencing this specific example, I am attempting to include subtle in my project, but TypeScript is throwing an error: Property 'subtle' does not exist on ...

Tips for customizing the background of form inputs in React-Bootstrap

Currently, I have a next.js project with react-bootstrap. I am attempting to change the default blueish gray background color (#e8f0fe or rgb(232, 240, 254)) that bootstrap uses for form inputs to white. To achieve this, I am customizing the bootstrap var ...

Undefined is returned after resolving - React - JavaScript API

Learning React and JavaScript is a bit challenging for me, especially when it comes to understanding how Promises and resolving work. I'm currently working on an API to log into an application with an internal SQL database. The queries are functionin ...

WebStorm 6 does not recognize the post method in Node.js Express

I recently started learning about node.js and decided to experiment with the express module in my application. Everything was going well until I attempted to use the app.post method. I am developing my app on WebStorm 6.0.2 and it doesn't seem to reco ...

experiencing difficulty with a background image that is failing to display

I'm having a hard time getting my background-image to show, even though I know it should be an easy fix. Here's the code for the div class where I want the background to display: .sun-face{ background-image: url("./images/Sun_face.svg"); } ...

Maintain the webpage content even after submitting a form with a file attachment on the same page

I am in the process of creating a secure webpage exclusively for our members. This page will allow members to access their personal data stored in the database and upload files as needed. One concern I have is how to return to the member page with all the ...

Struggling with implementing ng-repeat in AngularJS for displaying HTML content

I stumbled upon a post that covers pretty much what I'm trying to achieve: AngularJS - Is it possible to use ng-repeat to render HTML values? Currently, the code appears like this and displays correctly as text: <div ng-repeat="item in items.Item ...

Encountering difficulties in creating an app with Apache Cordova

After setting up the proxy settings, I attempted to create a new app named "hello" using Cordova with the following commands: npm config set proxy http://proxy.company.com:8080 npm config set https-proxy http://proxy.company.com:8080 The creation comman ...

TinyMCE - Utilizing selection.setContent along with getContent for the Warp Button

I am looking to implement a button that will wrap content with all tags. Snippet of Code: editor.addButton('MobileToggleArea', { text: '<M>', icon: false, onclick: function (){ editor.selection. ...