Scroll effortlessly with wrapping divs

Hey there! I've been experimenting with the Smooth Div Scroll plugin which you can find on their website here:

The implementation is pretty simple. I'm using the touch example, but with a twist - instead of images, I am using Divs to scroll through.

<div id="makeMeScrollable">
  <div class='item'>One</div>
  <div class='item'>Two</div>
  <div class='item'>Three</div>
  <div class='item'>Four</div>
  <div class='item'>Five</div>
  <div class='item'>Six</div>
  <div class='item'>Seven</div>
  <div class='item'>Eight</div>
  <div class='item'>Nine</div>
  <div class='item'>Ten</div>
</div>

I have included my js code below:

$(document).ready(function() {
  $("#makeMeScrollable").smoothDivScroll({
    hotSpotScrolling : false,
    touchScrolling : true,
    manualContinuousScrolling : false,
    mousewheelScrolling : false
});

Here is the accompanying CSS:

.item {
  height: 35px;
  width: 245px;
}

#makeMeScrollable {
  width: 100%;
  position: relative;
  border: solid 1px black;
  margin: 43% 0% 0% 0%;
}

#makeMeScrollable div.scrollableArea div {
  position: relative;
  display: block;
  float: left;
  margin: 0;
  padding: 0;
  border: black solid 1px;
  color: white;
  background-color: #1E90FF;
  text-align: center;
}

However, I encountered an issue where the tenth div appears to be wrapping around underneath the first one. It seems that the wrapper div created by the scrollable function may be a few pixels too short.

I attempted to manually adjust the size in Chrome Developer tools and it seemed to work. So perhaps dynamically extending the wrapper could solve the problem.

Unfortunately, I am unable to provide a screenshot at this time as I am new to this platform. Any assistance would be greatly appreciated!

Answer №1

What happens if you take out the border from the CSS style?

#makeMeScrollable div.scrollableArea div {
  position: relative;
  display: block;
  float: left;
  margin: 0;
  padding: 0;
  border: none;
  color: white;
  background-color: #1E90FF;
  text-align: center;
}

Can you set a fixed width for the div elements? For example:

#makeMeScrollable div.scrollableArea div {
  position: relative;
  display: block;
  float: left;
  margin: 0;
  padding: 0;
  border: black solid 1px;
  color: white;
  background-color: #1E90FF;
  text-align: center;
  width: 300px;
}

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

The Datejs library is experiencing issues following an upgrade to jQuery 3.x

I'm currently working on a node.js project that utilizes the Datejs library. However, after updating our local jQuery file from version 1.9.1 to 3.6.0, this library has stopped functioning properly. Here is a snippet of the code: var today = Date ...

Troubleshooting the issue of browser prefix injections not functioning properly in Vue when using the

I've spent an entire afternoon on this issue and I'm completely stuck. After realizing that IE11 doesn't support grid-template, I learned that I need to use -ms-grid-columns and -ms-grid-rows instead. I am attempting to generate CSS and inje ...

Retrieving information from a Vue component using AJAX

One of the components in my Vue project is named "testrow". It contains a form with two selections: "description" and "parameter". I need to make sure that the "parameter" changes based on the selected 'description' value stored in my database. T ...

Tips on using jQuery to horizontally align an element in the viewport

Although this question has been raised before, my situation is rather unique. I am currently constructing an iframe for future integration into a slideshow component on the website. The challenge lies in the fact that I have a dynamically sized flexbox th ...

The functionality of the submit form is encountering issues upon integration of Ajax requests

Hello everybody! I am currently creating a dynamic form for editing specific classes, but I am facing an issue with the ajax call not working. Below is the HTML code for the form: <form id="userDataForm" name="userDataForm" th:acti ...

Is there a way to create a JavaScript function that relies on a successful form submission?

After attempting to modify a post on Stack Overflow, I am facing issues with my JavaScript code. As a beginner, it's possible that I overlooked something in the code causing it not to work as expected. The project I'm working on involves creatin ...

Changing the Appearance of the RStudio Editor

I am exploring options to customize an RStudio Editor Theme to personalize the colors. My current setup includes RStudio version 0.99.473 on Windows 10. After reviewing Any way to change colors in Rstudio to something other than default options?, which wa ...

Issue with CSS color gradient transparency

I've successfully implemented a gradient that transitions from transparent to white by using the following CSS code: linear-gradient(to right, transparent, white) If you want to see it in action, click on this link: http://jsfiddle.net/fs8gpha2/ Al ...

Collapsed Grid System

Is it possible to create a CSS grid system that meets the following requirements: The grid should have arbitrary height (with consistent width) and when a grid overflows, it should stack vertically underneath the preceding grid, regardless of other grid ...

Issues with data within a Vue.js pagination component for Bootstrap tables

Currently, my table is failing to display the data retrieved from a rest api (itunes), and it also lacks pagination support. When checking the console, I'm encountering the following error: <table result="[object Object],[object Object],[object Ob ...

Press a button to link a click event handler to another button

function example() {console.log('example');} $('#button1').click(function(){ $('#button2').onclick = example(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> ...

Retrieve or extract information stored in a JSON array as a text string

After receiving a JSON Response, it contains: [{"name":"value 1"}] In my html.twig file, I am attempting to extract this value using the following code snippet: // extracting route parameter in JavaScript var for slug and confChecked $ ...

Is there a way to create an HTML popup that automatically opens a link and an image file side by side

Can a popup code be created to automatically open both a link and an image side by side? ...

Transmit text from tinyMCE through AJAX in MVC architecture with PHP

I am currently facing an issue while trying to send POST data in the form of an array containing email elements such as subject and message. The problem arises when using tinyMCE for the subject part, which is not being sent through successfully. All other ...

"The jQuery colorpicker function is not functioning properly when applied to newly added elements

I've got these amazing gadgets with a cool sliding box feature inside. Initially, there are two widgets visible on the page, but you have the option to add or delete a widget as needed. Within the sliding box, there is a color picker tool. Interestin ...

Switching between fixed and unfixed divs causes two absolute divs to alternate

I am currently working on a code to keep a fixed div ("two") in place between two absolute positioned divs ("one" and "footer") while scrolling. However, there is an issue that arises when the browser window is resized. The distance between the footer and ...

Analyzing Date Strings Retrieved From a MySql Database

In my MySQL database, I have a relationship that stores dates as varchar along with other attributes. This is how it looks: Answers answerId answer questionId date I am working on a web application where the user can select a &apo ...

When flex items are stacked in a column, the bottom portion may be truncated

(Edit) Check out the codepen example here. I am working on creating a stack of cards using Vue.js and flexbox to showcase different apps on my website. Each card is represented by a component and I utilize Vue's `for` function to display cards with t ...

how do I modify my JavaScript code to achieve the desired outcome

How can I program a button to disable after being pressed 10 times in less than a minute, but continue counting if not pressed for 1 minute? function buttonClicked() { if (totalCount + accCounter > 9) { document.getElementById("btn").disabled = ...

angularjs bootstrap carousel not functioning as expected

HTML How do I apply an active class to the first image? I am trying to create a slideshow with images from a database but encountering issues. <div id="myCarousel" class="carousel slide" data-ride="carousel"> <div ...