Tips for creating a scrollable section within a div row using clarity design instead of bootstrap formatting

My current project combines Angular with .NET Core, and I am encountering difficulties in styling one particular component.

This component consists of a row with two columns. The first column is empty while the second column contains another row divided into multiple columns filled with random numbers. My goal is to make only the second column horizontally scrollable, leaving the first column static.

(Please note that the random number filling is purely for content demonstration purposes.)

I have attempted to use white-space: nowrap in conjunction with overflow-x: auto to enable scrolling within the desired columns, but instead of achieving the intended effect, the columns are simply stacking on top of each other.

<div class="clr-row ">
  <div class="clr-col-2" style="background-color:aqua">
    <span >.</span>
  </div>
  <div class="clr-col-10" style="overflow-x:auto; width:100%; white-space:nowrap;">
    <div class="clr-row">
      <div class="clr-col" style="background-color:rebeccapurple">
        <span>1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 </span>
      </div>
      <div class="clr-col" style="background-color:brown;">
        <span>2 2 2 2 2</span>
      </div>
      <div class="clr-col" style="background-color:burlywood;">
        <span>3 3 3 3 3 3 3 3 3 3 3 3 3 3</span>
      </div>
      <div class="clr-col" style="background-color:cadetblue;">
        <span>4 4 4 4 4 </span>
      </div>
     <!--More columns go here-->
    </div>
  </div>
</div>

The objective is to make only the second column, which holds a row of numerous columns with random numbers, horizontally scrollable. The first column should remain fixed.

Referencing the screenshot linked below, my current output shows the second column's rows stacked on top of each other instead of providing the expected scrolling functionality. https://i.sstatic.net/aNaeQ.jpg

Answer №1

I'm not entirely clear on the issue you're facing, but one solution could be to utilize position: fixed in order to make the first row stay fixed.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="clr-row ">
  <div class="clr-col-2" style="background-color:aqua; position:fixed; width:100%; top:0;">
    <span>.</span>
  </div>
  <div class="clr-col-10" style="overflow-x:auto; width:100%; white-space:nowrap;">
    <div class="clr-row">
      <div class="clr-col" style="background-color:rebeccapurple">
        <span>1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 </span>
      </div>
      <div class="clr-col" style="background-color:brown;">
        <span>2 2 2 2 2</span>
      </div>
      <div class="clr-col" style="background-color:burlywood;">
        <span>3 3 3 3 3 3 3 3 3 3 3 3 3 3</span>
      </div> 
     //Remaining content...
    </div>
  </div>
</div>

Answer №2

I successfully resolved my issue by restructuring the layout of my columns. By wrapping the second column in a div tag and adding specific styling, I was able to create a scrollable effect. Inside this new div tag, I added another div tag to increase the width of the column, preventing them from stacking on top of each other.

<div class="clr-row ">
  <div class="clr-col-2" style="background-color:aqua">
    <span>.</span>
  </div>
  <div class="clr-col-10">
    <div style="overflow-x:auto;white-space:nowrap">
      <div style="width:1920px">
        <div class="clr-row">
          <!-- Other column styling included here -->
        </div>
      </div>
    </div>
  </div>
</div>

Note that my code is based on the clarity framework and not bootstrap, which may cause differences in appearance when running the snippet compared to the provided screenshot.

For reference, you can view the output in the following screenshot: https://i.sstatic.net/w0Vbi.jpg

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

Missing icons and images from the Assets folder when the "/" or "'" is removed from the URL

While working on an admin web project with Codeigniter, I faced a peculiar issue that seems to only arise when I either remove "/" after hiding index.php or add "/" without hiding index.php. In this scenario, the icons go missing and even profile pictures ...

Sass does not compile for optimization

My Sass compiler generated an overly large file for me, but it could be much smaller!! I checked the compiler settings and didn't find anything wrong! The issue might be with the compiler itself. It's also possible that there is a problem with my ...

Drop-down menu for every individual cell within the tabular data

I'm working with a large HTML table that looks like this: <table> <tr> <td>value1</td> <td>value2</td> </tr> <tr> <td>value3</td> <td>value4 ...

Incorporating a touch of dark opacity into an image

Check out the layout of my webpage here: https://i.sstatic.net/Ap4nx.jpg The background image I used is this one: https://i.sstatic.net/dIhLt.png I am trying to achieve a black transparent overlay on the image, similar to this: https://i.sstatic.net/FMdi ...

minimize javascript syntax (stackoverflow 2022)

I'm struggling with this puzzle game. Sometimes, when I start a new game, the pieces get shuffled incorrectly. I tried adding a function to fix it, but it doesn't seem to be working. It's really frustrating and I want to simplify the code as ...

I'm having trouble with my tablet view taking priority over my desktop view - what could be causing this issue?

Styling for different screen sizes: @media (min-width: 991px) and (max-width:768px){} .container, .container1, .container2 .container3{ float: left; } .container1{ width: 50%; } .container2{ width: 50%; } .container3{ width: 100%; } /**** ...

Utilizing Jquery: Extracting the value of a child element upon clicking the encompassing parent div

I've created a table-like structure using divs instead of tables (because I strongly dislike tables). However, I'm facing an issue. I want to be able to click on one of the div elements and extract the values of its child elements. <div cla ...

div with a fixed element inside that is scrollable

Check out this jsfiddle: http://jsfiddle.net/devboell/kjFps/ I am trying to create a div that overflows both horizontally and vertically. Additionally, I need an element that scrolls only horizontally while remaining fixed vertically. Here is an explanat ...

Experiencing issues with the redirect button on the navigation bar of my website

Video: https://youtu.be/aOtayR8LOuc It is essential that when I click a button on my navigation bar, it will navigate to the correct page. However, since the same nav bar is present on each page, it sometimes tries to redirect to the current page multiple ...

Failure to validate two dates, even when they are both in date format within AngularJS

Although it may seem silly to ask, I am confused as to why this is not working. Even though all the values appear fine in debug mode. My goal is to display an error if the productionStartFrom date is before the current date. Controller scope.currentDate ...

What is the best way to loop through an array of JSON data in order to consistently retrieve the initial JSON object?

How can I retrieve only the full highlight videos from the JSON object in the video array? { "response": [ { title: "United vd Chelsea", "videos": [ { "title": "Highlights&quo ...

Tips for avoiding anchor tag text from being split across two lines when resizing

One issue I am facing is with an anchor tag that displays the name of the logged-in person. The problem arises when resizing the browser window, causing the name to split across two lines. Is there a way to prevent this from happening? ...

Creating Personalized Checkboxes for Internet Explorer Versions 7 and 8

I am currently in the process of implementing custom checkboxes for my website. Everything is functioning smoothly on browsers such as IE9 and other modern ones. However, I am encountering issues with IE8 and 7. Below is a snippet of my CSS code: input[typ ...

The functionality of a button within an AngularJS directive is not functioning as intended

I am trying to use a directive twice on one page. Inside the directive, there is a button that should toggle between showing the two directives when clicked. However, I'm encountering an issue where the values are not changing even though the ng-click ...

The ideal caret position while utilizing flexbox for centering within a contenteditable element

After testing on OSX Chrome 45, it appears that align-items: center; works for content alignment, but there is an issue with caret positioning in an empty editable field until text is typed. Is there a solution to this problem that doesn't involve ad ...

Text field auto-saving within an iFrame using localStorage is not functioning as expected

My goal is to create a rich text editor with an autosave feature using an iframe. Although each code part works individually, I am struggling to combine them effectively. View LIVEDEMO This graphic illustrates what I aim to accomplish: The editable iFram ...

Get rid of the box-shadow on the Vuetify element

I currently have a special-table component that includes a box shadow when the row is expanded https://i.stack.imgur.com/8zgjp.png I am aiming for the removal of the box-shadow effect. After inspecting the console-style tab, I identified https://i.stac ...

Unable to substitute a value using the useState hook in React

Whenever I click a key, I attempt to update the value of a variable but it appears not to be working as intended. ↓ The current implementation is not effective and needs improvement import React, { useState, useEffect } from 'react'; const Li ...

Make sure to close all your tags properly in PHP

Within my <textarea>, I am giving users the ability to submit content. The specific tags I want to allow include <b>, <i>,<blockquote>, and <del>. In order to prevent any unclosed tags since this content will be displayed on t ...

What is the method for creating two separate columns that can scroll independently?

I am faced with a challenge involving a modal that contains two columns. My goal is to make these columns scrollable independently of each other while ensuring the scrollbar remains hidden. Thus far, I have managed to make the row scrollable with a hidden ...