Is there a way to hide the horizontal bar and implement left and right buttons for horizontal scrolling?

Is it possible to hide the horizontal bar and implement left and right buttons for horizontal scrolling, including touch-enabled scrolling on mobile devices?

You can view my markup in this jsfiddle. Thank you!

<div class="ui grid container r-feat-prod-row">
<div class="row">

  <div class="left floaded fourteen wide column">
    <div class="ui container">
      <div class="ui segment r-feat-col">
        <h4 class="ui horizontal divider header">Featured Category</h4>
        
        <div class="scroll">
          <div class="r-content">

            <div class="r-prod-card">
              // content hidden for brevity...
            </div>
            
            <div class="i-prod-card">
              // content hidden for brevity...
            </div>
            
            <div class="i-prod-card">
             // content hidden for brevity...
            </div>
            
            <div class="i-prod-card">
              // content hidden for brevity...
            </div>
            
           // remaining cards hidden for brevity...

          </div>
        </div>
        
      </div>
    </div>
  </div>
  
  <div class="one wide column">
    // ad content hidden for brevity...
  </div>

</div>

Answer №1

Due to limitations in browser styling for scroll bars, I have utilized overflow-y:hidden; on the parent element to conceal the scroll bar. The buttons can be customized as desired, but I have positioned them at the bottom.

See it in action: http://jsfiddle.net/hopkins_matt/muL9mrL1/1/

CSS:

/* featured column */

.ui.segment.i-feat-col {
    overflow-y:hidden;
}

.i-feat-prod-row {
    margin-top: 30px !important;
}
h4.ui.horizontal.divider.header {
    color: #6CAF2B;
}
.i-feat-col {
    height: 250px !important;
}
.i-prod-card {
    width: 170px;
    height: 170px;
    position: relative;
    display: inline-block;
    background: #ffffff;
    box-shadow: 0px 1px 2px 0 rgba(34, 36, 38, 0.15);
    margin: 0.5rem 1em;
    margin-top: auto;
    padding: 1em 1em;
    border-radius: 4px;
    border: 1px solid rgba(34, 36, 38, 0.15);
    top: 6px;
}
div.scroll {
    height: calc(100% + 10px);
    overflow-x: hidden;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling-x: touch;
}
div.scroll:hover {
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
}
.i-content {
    white-space: nowrap;
}
.i-feat-header {
    text-transform: capitalize;
    font-size: 12px;
    white-space: initial !important;
    text-align: left;
    line-height: 17px;
    letter-spacing: normal;
    padding-right: 11px;
    padding-left: 11px;
    clear: right;
}
.i-feat-header-price {
    color: #F44336;
    font-weight: 500;
    font-size: 15px;
}
.i-feat-img {
    display: block;
    max-width: 140px;
    width: auto;
    height: auto;
}
.dimmable {
    position: absolute;
}

JS:

$(function () {
    $('.i-prod-card .image').dimmer({
        on: 'hover'
    });
});

function scrollHoz(dir) {
    if (dir == 'L') {
        $('.scroll').animate({
            scrollLeft: "-=" + 250 + "px"
        });
    } else if (dir == 'R') {
        $('.scroll').animate({
            scrollLeft: "+=" + 250 + "px"
        });
    }
}

HTML:

<div class="ui grid container i-feat-prod-row">
    <div class="row">
        <!--featured column starts-->
        <div class="left floaded fourteen wide column">
            <div class="ui container">
                <div class="ui segment i-feat-col">
                     <h4 class="ui horizontal divider header">Featured Category</h4>

                    <!--featured products starts-->
                    <div class="scroll">
                        <div class="i-content">
                            <div class="i-prod-card">
                                <div class="blurring dimmable image ">
                                    <div class="ui dimmer">
                                        <div class="content">
                                            <div class="i-feat-header">
                                                <div class="ui inverted">Product long title second line Product long title Product...</div>
                                                <div class="ui divider"></div>
                                                <div class="meta"> <span class="i-feat-header-price inverted">MVR 100,000.00</span>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <img class="i-feat-img" src="https://s3.amazonaws.com/upload.uxpin/files/209268/214371/watch.png">
                                </div>
                            </div>
                            
                            --truncated for brevity--
                            
                        </div>
                    </div>
                </div>
                <!--featured products ends-->
            </div>
        </div>
        
        <!-- button section -->
        <button onclick="scrollHoz('L')">Left</button>
        <button onclick="scrollHoz('R')">Right</button>
        <!-- button section ends -->
    </div>
</div>

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

Obtain keys from an object implemented with an interface in TypeScript

Is it possible to retrieve the actual keys of an object when utilizing an interface to define the object? For example: interface IPerson { name: string; } interface IAddress { [key: string]: IPerson; } const personInAddressObj: IAddress= { so ...

Laravel Troubles: The Predicament of Handling Ajax Requests - Error 400

Here is the JavaScript code snippet: $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' } }); $.ajax({ type : 'POST', url: 'test', data: data, success: ... }); An issue where a 400 error occurs h ...

Error encountered: The jQuery function was not invoked while attempting to retrieve geoJSON data through an Ajax request from a Node.js server

I've been struggling to pass geoJSON data from a Node.js app on one server to a web app running on another server. Despite searching through numerous resources, I haven't been able to resolve the issue. Using the RestEasy extension on Chrome, my ...

Error Message "Alexa.create is not a valid function" encountered while using the Alexa HTML Web API on the Echo Show 10

Here is the HTML code for my custom Alexa Skill. <head> <script src="https://cdn.myalexaskills.com/latest/alexa-html.js"> </script> </head> <body> var alexaClient; Alexa.create({version: '1.0'}) .t ...

React application not functioning on localhost:3000 despite successful compilation with no errors, only displaying the title on localhost but failing to show any content

I recently started developing a new website with React. Everything was running smoothly on localhost until I made some changes, and now the homepage content is not displaying when I visit localhost:3000. I suspect there may be an issue with my routing or s ...

jQuery Decimal Calculations

Could anyone help with how to format decimal numbers in these calculations and also include the interest code: function reCalc(borrowValue) { $("#targetVal").html("&pound;" + borrowValue); var borrowBC = Math.floor(borrowValue * 1.25); var ...

Creating Shadows in Swift with Xib for TableView

I am currently working on: Attached is a screenshot from an iPhone: This is the code snippet in question: cell.shadowLayerView.layer.masksToBounds = false cell.shadowLayerView.layer.shadowOffset = CGSize(width: 0, height: 0) cell.shadowLayerView.layer.s ...

The Smarty global URL is trying to call jQuery, but it is unable to do so

Currently, I am in the process of developing a unique home page layout for my Prestashop website. I have chosen not to utilize pre-designed layouts as I prefer a minimalist approach for my homepage without elements like header, footer, or menu. By leve ...

CSS-Inlined equivalent for an empty td cell

Is there an alternative inline CSS solution for the following CSS selector: table td:empty { visibility: hidden; } What should be used instead of this? <table style="???"> <tr> <td></td> <!-- content will be added late ...

``Toggling all classes in a click event instead of toggling the correct block

Within my collapsed/collapsible blocks, the first block is open while the second and third are closed. The opening and closing function works correctly, but I am struggling to figure out how to change the icons so that they update only for the relevant blo ...

Centered iframe within a div

I am trying to center my iframe within a white box and need some assistance with this. I want the iframe to be in the middle of the white box rather than its current position at the moment. game1.html: <html> <head> <title>R ...

Angular popup refusing to close (forcing $scopes to communicate)

I have encountered an issue with a simple angular modal that is triggered using angular ui.bootstrap. The modal opens successfully, passes values, but struggles to close or cancel. I suspect it might be an issue with the $scopes not communicating effective ...

Removing a value from a JSON object by utilizing the .map function

My JSON object is structured as follows: [{"box":1,"parent":[],"child":[{"boxId":2},{"boxId":3}]},{"box":2,"parent":[{"boxId":1}],"child":[]}] I am attempting to remove the element "child":[{"boxId":2} with boxId=2 from the object. I have tried using a , ...

Steps to select an option from a drop-down menu that does not have an ID assigned

How can I interact with a drop-down element that appears after clicking on an item? <div class="field loan-selection"> <label class="field__body"> <div class="field__label">Nettokreditbetrag <!-- -->&nbs ...

Is it beneficial to integrate web applications directly into the content of websites?

I'm exploring how web apps integrate with websites and considering if they can potentially replace traditional website structures altogether. Currently, my website operates as a server delivering static HTML pages with some embedded JS. While this se ...

What is the best way to eliminate the input range in a React date range picker?

Here is an image illustrating a date range picker: https://i.stack.imgur.com/pwKaI.png I am looking to remove the labels for days before today and starting from today in the date range picker. How can I achieve this? Below is my code snippet: class Better ...

Typescript's way of mocking fetch for testing purposes

I have a query regarding the following code snippet: import useCountry from './useCountry'; import { renderHook } from '@testing-library/react-hooks'; import { enableFetchMocks } from 'jest-fetch-mock'; enableFetchMocks(); i ...

Issues with retrieving JSON data from Google Books API object

I've been working on retrieving data from the Google Books API and displaying the titles of the first 10 results on a web page. The site is successfully making the request, and I have a callback function that handles the results as shown below: funct ...

Having trouble with PHP upload to server file function

This code seems to be error-free, but unfortunately it is not inserting the file into the database and destination folder upon clicking the upload button. HTML Form <html> <body> <form action="includes/parts-cat/zip ...

Strategies for detecting when the focus has moved away from a Div

I'm currently developing a dynamic form that generates multiple Divs. My goal is to detect when the focus is lost from an entire div, not just from one input field. https://i.sstatic.net/YopGs.png As shown in the image, I have several identical form ...