Place a list with scrolling and overflow features side by side

Having trouble getting my headers to scroll with overflow auto and white-space nowrap. Can't figure out why it's not working.

I want to create hyperlinks within headers to link to specific parts of the website. I have the code for hyperlinking set up, but I'm struggling to keep all the content in the same line, especially on mobile devices.

Current look of the Headers: ! https://ibb.co/xhtXHF4

Desired look of the Headers, with a scroll bar but still in the same line: ! https://ibb.co/DLyzN0J

Tried adding overflow:auto and white-space:nowrap to the code but it's not taking effect. Any suggestions on how to achieve having all Headers in the same row with a scrolling bar when space is limited?

<script type="text/javascript">
    
    $(document).ready(function() {
  $('a').click(function() {
    $('#url').html($(this).prop('href'));
  });
});

</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div.pentaho-rounded-panel-bottom-lr {
  display: none;
  overflow: auto;
  white-space: nowrap;
}

div.pentaho-rounded-panel-bottom-lr .pentaho-rounded-panel-bottom-lr {
  display: block;
}

:target {
  display: block !important;
}

a:link, a:visited{
  background-color: #E1AFB3;
  color: #030303;
  padding: 14px 25px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

a:hover {
  background-color: #C3414D;
}

</style>
<a href="#Header1">Header1</a>
<a href="#Header2">Header2</a>
<a href="#Header3">Header3</a>
<a href="#Header4">Header4</a>

<div id="Header1" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="Header1" class="pentaho-rounded-panel-bottom-lr">
    This is the content from Header 1
  </div>
</div>

<div id="Header2" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="Header2" class="pentaho-rounded-panel-bottom-lr">
    This is the content from Header 2
  </div>
</div>

<div id="Header3" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="Header3" class="pentaho-rounded-panel-bottom-lr">
    This is the content from Header 3
  </div>
</div>

<div id="Header4" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="Header4" class="pentaho-rounded-panel-bottom-lr">
    This is the content from Header 4
  </div>
</div>

Appreciate any suggestions provided. Thank you.

Answer №1

To enhance the appearance of all header divs, you can group them inside a single div and apply styling as shown below:

#Headers {
  width: 600px; //example
  display: flex;
  flex-direction: row;
  flex-wrap: no-wrap;
  overflow-x: scroll;
}
<div id="Headers">
  <div id="Header1" class="pentaho-rounded-panel-bottom-lr pentaho-shadow>">
    <div id="Header1" class="pentaho-rounded-panel-bottom-lr">
      This is the content from Header 1
    </div>
  </div>

  <div id="Header2" class="pentaho-rounded-panel-bottom-lr pentaho-shadow>">
    <div id="Header2" class="pentaho-rounded-panel-bottom-lr">
      This is the content from Header 2
    </div>
  </div>

  <div id="Header3" class="pentaho-rounded-panel-bottom-lr pentaho-shadow>">
    <div id="Header3" class="pentaho-rounded-panel-bottom-lr">
      This is the content from Header 3
    </div>
  </div>

  <div id="Header4" class="pentaho-rounded-panel-bottom-lr pentaho-shadow>">
    <div id="Header4" class="pentaho-rounded-panel-bottom-lr">
      This is the content from Header 4
    </div>
  </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

Display various child components in a React application depending on the current state

I'm currently developing a brief React quiz where each question is represented as an independent component. I aim to swap out the current question component with the next one once a question is answered. Here's the present state of my root compon ...

Preselecting items in PrimeNG Checkbox: A step-by-step guide

How can I ensure that the already selected item is displayed upon loading this div? The code in `rp` consists of an array of type Permission with one element, which should be automatically selected. What could be causing the issue? Here is the HTML snippe ...

Spread out a div across a container's width

Currently, I am struggling to modify my css and html in order to have a div expand horizontally into a scrollable div. However, all I seem to get is the content stacking once the width limit is reached. Take a look at this fiddle for reference. The absol ...

An asynchronized code block processes an array of multiple Ajax deferred calls, concluding with a synchronous final code block

I am new to the world of jQuery and AJAX and I'm currently exploring how deferrals and promises can help me solve a particular issue. Here's what I'm trying to achieve: I want to make calls to multiple URLs, process the returned results in p ...

ReactJs allows for fluid scroll animations that persist as long as the mouse is clicked or a button

Just some background information: I'm aiming to replicate the scrolling effect seen in Etsy's product image thumbnails carousel. Essentially, when you hover over the top part of the div, it automatically scrolls down until the last image is reve ...

How to host two Node.js socket.io projects on one URL

My Nodejs server is hosted on Amazon Lightsail. I have successfully connected to it and configured Apache for Nodejs. I am working with 2 Nodejs socket.io projects and I want to access both of them using a single URL. Below are the links in Nextjs: const ...

Perform a jQuery function and SQL query when a selection is made in a dropdown menu

Struggling to execute a SQL query on drop-down menu selection. Here's my current code: <script> $('#templateid').change(function(DoUpdateOnSelect) { $.post('page.edit.php?page_id=(-->Need help in retrieving this id from the pa ...

Layer one div background image over another div background image

My goal is to have the Mario image displayed on top of the background seen in the screenshot below. While I've managed to get it working, I'm struggling to center the Mario image properly over the background. Additionally, I would like to elimina ...

Sending properties within components using #createElement in React-Router is a convenient way to pass data locally

Have you ever wondered where the parameters Component and props are coming from in the React-Router documentation? // Here is the default behavior function createElement(Component, props) { // ensure all props are passed in! return <Component {... ...

What is the impact of sending a JavaScript request to a Rails method every 15 seconds in terms of efficiency?

I have a method that scans for notifications and initiates a js.erb in response. Here is the JavaScript code triggering this method: setInterval(function () { $.ajax({ url: "http://localhost:3000/checkNotification", type: "GET" }); }, 15000); ...

If the visitor navigated from a different page within the site, then take one course of action; otherwise

How can I achieve the following scenario: There are two pages on a website; Parent page and Inside page. If a user navigates directly to the Inside page by entering the URL or clicking a link from a page other than the Parent page, display "foo". However, ...

When jQuery is combined with extending Object.prototype, the result is an error message that states, "c.replace is not

In my open source project, I am utilizing jQuery 1.5 and the following snippet is included in my JavaScript code: /** * Object.isEmpty() * * @returns {Boolean} */ Object.prototype.isEmpty = function () { /** * @deprecated Since Javascript 1.8 ...

Arranging Div Elements in a Specific Layout

I am currently experimenting with http://jsfiddle.net/ngZdg/ My main goal is to create a parallax website, but I am facing some challenges with the initial layout. I am aiming for the following design: ------------------------------------- | ...

What is the best way to align a div in the middle of an input-group div?

When dealing with a nested div, where the parent div is styled with an input-group class, my goal is to have the nested div centered within the available line or on the next free line space. This is the desired layout I want to achieve regardless of the n ...

Transforming PHP Variable Using Ajax

I have a variable called $type and I need it to be either month or year. This change should occur when a div is clicked. I attempted to use an onclick event with an ajax call. The ajax call and the variable are both in the same script (index.php). Within ...

Using jQuery to switch between displaying full text and truncated text

How can I toggle the hidden text that appears after using the .slice function to remove the first 100 characters? This is the code snippet I am currently working with: .html <div class="col-sm-12"> <p class="pdp-product-description">Th ...

Can you explain the distinction between JSON syntax and object assignment in programming?

While exploring the Twitter Client example on Knockoutjs, one may notice that some properties are included in the JSON object while others are assigned outside of it. What distinguishes these two approaches? And why can't methods such as findSavedList ...

Events in d3.js are properly registered, however they are not being triggered as

After creating an enter section that transitions to set the opacity to 1, I encountered an issue where the 'click' event on the circle worked but not on the text. Interestingly, when I replaced the 'text' with a 'rect' and se ...

Restricting the frequency at which a specific key value is allowed to appear in JSON documents

Within my JSON file, there is an array structured like this: { "commands": [ { "user": "Rusty", "user_id": "83738373", "command_name": "TestCommand", "command_reply": "TestReply" } ] } I have a requirement to restrict the num ...

Utilizing the map function to incorporate numerous elements into the state

I'm struggling with 2 buttons, Single Component and Multiple Component. Upon clicking Multiple Component, my expectation is for it to add 3 components, but instead, it only adds 1. import React, { useState, useEffect } from "react"; import ...