Creating a CSS grid layout with a scrollbar positioned on the left side and content filling from left to right

How can I move the scrollbar to the left while keeping ng-repeat population from left to right?

I'm using an ng-repeat to fill a grid that is 3 by X (Width by height). By default, the scroll bar appears on the right side. I want to position it on the left, so I tried using direction: rtl;. However, this causes my ng-repeat data to fill in from right to left instead of left to right.

As far as I know, direction:rtl is the only way to move the scrollbar to the other side. Is there another method or tool that I am overlooking to achieve this without using direction: rtl? Alternatively, is there a way to revert the content back to left-to-right alignment?

Here's my HTML:

<div class="h-blue-holding-grid">
  <div class="blue-holding-item" ng-repeat='img in recipeArray'>
    <div class="h-blue-holdingImg"><img src="/imgs/redhead.png" width="45" height="45"></img></div>
    <div class="h-blue-smalltime">{{Math.floor(img.data.data.start_time_ms/1000/60)}}:{{img.data.data.start_time_ms/1000%60}}<span ng-if="img.data.data.start_time_ms/1000%60 < 10">0</span></div>
    <div class="h-blue-smallfont">{{img.data.data.name}}</div>
  </div>
</div>

And here's my CSS:

.h-blue-holding-grid{
  width: auto;
  display: grid;
  grid-template-columns: 33% 33% 33%;
  grid-gap: 3px 3px;
  margin-right: 5vh;
  height: 25.5vh;
  overflow-y: scroll;
  direction: rtl;
}
.blue-holding-item{
  width: 100%;
  height: 8vh;
  text-align: left;
  background-image: url(/imgs/gradient_blue.png);
  background-size: 20vh 8vh;
  color: white;
  font-family: "Segoe UI";
  font-weight: bold;
  display: grid;
  grid-template-columns: auto auto;
}
.h-blue-holdingImg{
  grid-row-start: 1;
  grid-row-end: 3
}

Thank you,

Answer №1

Is there a method to adjust the scrollbar position without using direction: rtl?

In modern browsers, you can change the scrollbar side by applying transform: scaleX(-1) to a parent <div>, and then do the same for a child "sleeve" element.

HTML

<div class="parent">
  <div class="sleeve">
    <!-- content -->
  </div>
</div>

CSS

.parent {
  overflow: auto;
  transform: scaleX(-1); //Reflects the parent horizontally
}

.sleeve {
  transform: scaleX(-1); //Flips the child back to normal
}

For more information, check out this answer on How to position a div scrollbar on the left hand side?

Answer №2

To achieve this, simply include direction:ltr in the child elements. In your case, it can be implemented as follows:

.blue-holding-item {
    direction:ltr;
}

Does this meet your requirements?

===== Updated Information =====

It's important to note that this issue is related to CSS rather than ng-repeat, and it functions as intended. If you can modify the HTML, just add an additional div around the .blue-holding-item with direction:ltr; for it to work seamlessly.

View a live demonstration here: https://codepen.io/anon/pen/wVeyQg

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

Spacing between Div tags

Struggling with a tricky HTML cross-browser problem. The site was built by multiple people, making it quite messy, but needs to go live as soon as possible! Each of the 4 page layouts on the site are different and handled by separate classes. However, whe ...

Excess space creating horizontal and vertical scrolling issues on an HTML webpage

Currently, I am experimenting with CSS effects. In my code, I have included div elements to display balls on the document body, each with random sizes and colors. However, an unexpected issue has arisen - excess scroll space is being generated due to the c ...

Ensuring the accuracy of the angular-formly form definition

I am currently involved in a project where users can input a JSON formly form definition that gets saved into the database. This definition will later be utilized to create a form. Before storing this JSON definition in the database, I need to validate it ...

Animations with absolute positioning not rendering correctly in Safari

I recently created a basic animation that involves setting an element to "position: absolute" in order to translate it. Everything functions perfectly as intended on Chrome, however, when testing it on Safari, the absolute positioning seems to be completel ...

Content being pushed upward by Bootstrap modal

I've spent the last few hours working with the bootstrap modal, but I'm encountering some issues. Despite my thorough search, I haven't found anyone facing a similar problem. Here is the structure of my modal: <!-- Modal --> <div ...

javascript Incorrectly using location.reload will not refresh the page as intended

My goal is to refresh a page every time a user clicks a button so the page reverts back to its original source code. However, I am facing an issue where the location.reload() function is being executed after the code instead of at the beginning. btn.addEve ...

What is the best way to eliminate YouTube recommended videos that appear at the conclusion of my video?

I am attempting to incorporate my own YouTube video onto my blog without having recommended videos display at the end. I have tried using ?rel=0 and &rel=0 but they do not seem to be working. <iframe class="embed-responsive-item" src="https://www.y ...

highcharts-ng expands in flexbox without contracting

I've encountered an issue while trying to incorporate a highchart within a flexbox container. The chart expands along with the container without any problems, but it fails to contract when the container size decreases. My current setup involves angul ...

Enhanced User Experience Through Triggered Content Recommendations based on Scrolling Patterns

When a user scrolls beyond a certain point on a webpage, I would like a recommended content popup to slide out from the right side at the bottom of the page. An excellent example can be seen on USAToday where a blue recommended box appears as you scroll d ...

The variable $_FILE fails to retrieve the file, resulting in PHP displaying an undefined variable error

I am facing an issue where I am unable to get the image file sent from an HTML form to insert it into a database. The other variables are being posted successfully, as I have checked them by echoing, but the image file is not getting posted. I suspect that ...

Improved method for transferring multiple form input values from a child to a parent window

I am working on a project where I have a child window containing multiple radio buttons. My goal is to send all the selected values from these radio buttons to the parent window. Currently, I am achieving this by creating a JavaScript string that contains ...

Learn how to manipulate the DOM by dynamically creating elements and aligning them on the same line

Providing some context for my page: The section I have always contains a single input field. Below that, there is an "add" button which generates additional input fields. Since only one field is required on the screen, the following fields come with a "de ...

The code written inside the <script> tag seems to be malfunctioning when placed in the component.html file within VScode while working with

I'm facing an issue where the script tag for jQuery included in index.html is not being executed within the component.html. There are no errors detected when inspected. Additionally, I have used another script for a toast message box. <script sr ...

A guide to creating gradient borders using CSS

Does anyone have advice on applying a gradient to a border in CSS? I attempted using the following code: border-color: -moz-linear-gradient(top, #555555, #111111); Unfortunately, it did not work as expected. Can someone share the correct method for creat ...

What is causing these divs to shift apart instead of staying next to each other when the browser window is resized?

I am facing an issue with two of my divs not staying next to each other when resizing the browser window. They align perfectly when the window is wide, but as soon as I resize it to a narrower resolution, the right div moves below the left one: http://jsfi ...

Ensuring the validity of an Angular JS UI-select component when placed outside of

I am looking to validate a ui-select element on a button click event. The requirement is that the button should only be enabled when a value is selected in the ui-select. However, the challenge is that the button is located outside of a different div contr ...

Ways to conceal a div using ng-hide

Is there a way to make a div disappear using ng-hide? I have this code and I'm trying to hide the div with id="ApagarNA". The code displays a table with values, but some rows contain N.A in all 4 columns, and I want to hide those specific rows. For e ...

Mobile Iframe in Full View

Currently, I am working on a small project using Angular and Twitter Bootstrap. However, I have encountered a problem. I am trying to create a template that displays content in full screen upon clicking a button. The issue is that the iframe I am using wor ...

jQuery and ajax method are failing to insert data into the database

I am having trouble inserting data into the database using jQuery and Ajax. Can someone please assist me in figuring out if I'm doing something wrong? Here is the code snippet: form.html <!DOCTYPE html> <html> <head> & ...

The ng-click directive is not functioning properly when used within an ng-repeat loop

Trying to showcase products based on brands, but encountering issues with ng-click inside ng-repeat. However, ng-click outside the ng-repeat is functioning properly. Could there possibly be a conflict within ng-repeat...? Module var myApp = angular.modul ...