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

Navigating with Express while incorporating React

I am struggling to set up the routes for my web application using Express, as well as incorporating React for the front end. The issue lies in properly routing things when React components are involved. My index.html contains: <script> document.get ...

Grails is experiencing a surge of duplicate events being triggered simultaneously

In my _test.gsp layout, I have a 'click event' that is triggered when the layout is rendered as shown below. <div id="testid"> <g:render template="test"/> </div> When I click on the event in the _test.gsp layout, it trigge ...

Neglecting images on Zoom

Looking to scale up the elements on an HTML page by 50%, without affecting the resolution of images. Despite trying zoom: 150% in CSS3, it ends up zooming pictures as well, resulting in blurry visuals. Is there a way to enlarge all HTML components while ...

Struggling with certain CSS design elements

I'm encountering some CSS styling issues. The button in my form remains perfectly positioned when I resize the window, but the inputs are moving around. Why is this happening? Also, when a button is pushed, a h2 element with a little arrow needs to b ...

reconfigure form credentials with JavaScript

I am currently working on a form that includes a textbox and a button for submitting data using ajax. <input type="password" id="password" /> <button id="addaccount" onclick="showload();">Add</button> When the user clicks on the button, ...

Issue with FILE_APPEND and file_put_contents function not functioning as expected

My approach involves sending form data as JSON via AJAX to a PHP file, which then saves the JSON information in a text file on the server. An issue arises when using FILE_APPEND, as the data is not written to the file if the JSON content already exists wi ...

Using a dynamic image source in an Ionic 3 background

I am using ngFor to display a list of posts, each of which should have a unique background image. The getBackgroundStyle function is responsible for extracting the URL of the image from the post array. <div class="singlePost" *ngFor="let post of da ...

"Flashes of canvas in constant motion between animated scenes

I have a practical exercise to do for school, but I am very new to HTML/JS. The issue I am facing is that my canvas is flashing, like it erases one image and then quickly displays another. I want both images to be displayed at the same time. Here is the co ...

Is there a way to access an SD card by clicking on an HTML link using JavaScript?

UPDATE: I am seeking a way to embed an HTML file with JavaScript or jQuery that can directly access the contents of the SD card while being opened in a browser. Currently, I have posted code for accessing it through an activity, but I want to be able to d ...

What is the lowest opacity value allowed in CSS?

When adjusting the opacity value of a button in CSS, I have noticed that even when the opacity is reduced to 0.005, the button remains clickable to some extent. However, when reducing the value to 0.000000000000000000000000000000000001, the button becomes ...

At what point do browsers decide to round pixel fractions to whole pixels, and when do they choose not to do

I recall reading here on SO that using pixel fractions in CSS is generally advised against because browsers tend to round them to the nearest whole pixel. As shown in the example below, 0.3 pixels are indeed rounded to a full pixel: span { border: 0. ...

"Owlcarousel Slider: A beautiful way to showcase

Currently, I am working on a project that involves implementing a slider. Since I lack expertise in JavaScript, I opted to use a plugin called owlcarousel. The challenge I'm encountering relates to the sizing of the container for the items. I'm ...

Aligning a grid container in the middle

#panelb { background: lightblue; display: grid; grid-template-columns: repeat(auto-fit, 300px); } .card { background: gold; } .imgcard { display: block; width: 100%; margin: 0 auto; } <div id='panelb'> <div class=' ...

Animated slide-out menu with icon using jQuery

I am in the process of creating a menu using CSS and jQuery that will display an icon for each menu item. When a user hovers over a menu item for 0.5 seconds, I want it to slide slowly to the left to show the name of the menu. This is similar to what you ...

The functionality for the "OnChange" event in the <html:select> field does not seem to be functioning properly

My JavaScript function isn't functioning properly. I can't see any alert messages on my webpage. Can someone please assist me? Below is my HTML code function checkProjectStatus() { alert("Helloo"); var dropdownType = document.getElementById( ...

Issue with Modal Box: Datepicker not Displaying Correctly

I have implemented a modal box in my webpage. When I click on a text field where a datepicker is added, it does not display anything. However, when inspecting the element using Chrome's developer tools, I can see that the 'hasDatepicker' cla ...

Issue with React app: IconMenu does not expand when clicked

Seeking assistance with a react app and IconMenu from material-ui. I've been researching similar issues extensively but haven't found a solution yet :( In the code below, I am looking to manually trigger the expansion of a menu - this is essenti ...

Display information from Node.js on an HTML page

I am working on a nodejs project where I need to login on one page and display the result on another page using expressjs. Below is my code for login.ejs: <!DOCTYPE html> <html lang="en" dir="ltr"> <body> <form method="PO ...

Angular 2 component hierarchy with parent and child components

Currently, I am in the process of learning typescript and angular2. My attempt to incorporate parent and child components into my fiddle has not been successful. Despite conducting some research, I have encountered an error that states: Uncaught ReferenceE ...

Receiving the error message "Cannot find variable $"

Exploring a new feature to add growl notifications during test execution. This feature displays messages on the screen as tests run. Following the steps outlined at: Environment: - Machine: Windows 10 - Selenium Version: 2.53 - Browser: Firefox 49 Here ...