Set horizontal scrolling div to fit the size of its content

I have been working on a website with horizontal scrolling sections, using only CSS to achieve this effect. Currently, I am rotating the container to create a more 'natural' horizontal scrolling experience. However, I would like to adjust the width of the container based on the images it contains so that users cannot scroll beyond the images themselves. Below is my HTML and CSS code:

.slide {
  height: 80vh;
  background-size: auto 100vh;
  background-repeat: repeat-x;
  width: 2000vw;
}

.wrapper {
  display: flex;
  flex-direction: row;
  width: 2000vw;
  transform: rotate(90deg) translateY(-80vh);
  transform-origin: top left;
}

.outer-wrapper {
  width: 80vh;
  height: 100vw;
  transform: rotate(-90deg) translateX(-80vh);
  transform-origin: top left;
  overflow-y: scroll;
  overflow-x: hidden;
  position: absolute;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
<div *ngIf="ready" class="container-fluid" id="projects">
  <div class="outer-wrapper">
    <div class="wrapper">
      <div class="slide one">
        <img *ngFor="let image of images" class="img-fluid" [src]="image">
      </div>
    </div>
  </div>
</div>

Despite trying various combinations of CSS properties, I haven't found a solution that works consistently across different screen sizes.

Answer №1

Which of these options is closer?

In the first option, I eliminated the "slide one" div and directly used img tags inside the wrapper. Additionally, I removed the width setting from the .wrapper class.

For the second option, I utilized divs and background images that now cover the entire screen. To achieve this effect, certain adjustments were made in the .slide class.

If this aligns with your desired outcome, I will enhance this post to ensure others understand the changes made. However, if further modifications are necessary, let's collaborate on refining it.

(Images sourced from instagram.com attributed to Vola Udabe Randri, known as olaizolav)

Answer №2

After working through it, I was able to come up with a solution on my own. Utilizing vh (viewport height) units to define the width of the wrapper proved to be the crucial step in maintaining consistent proportions.

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

Perform an action when a button is clicked in a VueJs single-page application

How can I trigger the refreshMailList function when clicking on the mail-list component? This is my Vue instance with a custom mail-list component: Vue.component('mail-list', { props: ['inboxmail'], template: ` <div> ...

Image not appearing on basic HTML website

This particular issue has left me completely puzzled. After removing all the unnecessary elements from a problematic website, I am now left with an extremely basic and minimalistic site: <!DOCTYPE html> <html lang="en"> ...

Unable to verify the provided resource: Mailchimp

Welcome everyone to my first question posted on StackOverflow. I have tried my best to provide all the necessary details regarding the issue in order to seek assistance. If you require additional information, feel free to ask. To give a brief overview, I ...

I am looking to retrieve information from mongodb and then transform it into a JSON object using node.js. Can you guide

I am on a mission to retrieve data from a MongoDB database and transform it into a JSON object in Node.js. The goal is to be able to easily manipulate this data as if it were a simple JSON object. Here's the current code snippet I'm working with: ...

Enhancing Google charts with vertical line effects on hover

I am currently working on a project using google line charts and an angularjs directive. I am trying to figure out how to display vertical lines on hover, similar to how it is done on Google Trends, instead of having fixed lines. However, I have not been a ...

"Enhance your website with a dual-column layout using jQuery for

Hello, I am currently utilizing a fiddle link to move one div upward and another div downward simultaneously. While the left column is behaving as expected, I would like to achieve the same functionality for the right column as well. The link being used ...

Vue.js - Duplicate Navigation Error When Redirected to a New Page

I'm facing an issue with Vue.js and the NavigationDuplicated error. As I work on a web application that involves navigation across various pages, I encounter the "NavigationDuplicated" error unexpectedly. Even though I'm not attempting to naviga ...

Encountering a NoSuchElementException when transitioning from frame[0] to window[1] in Firefox GeckoDriver using Selenium with Python

Encountered an issue with the Firefox GeckoDriver browser where I receive an error stating `element not found`. The problem arises when I navigate from window[1] to frame[0], back to window[1], and then attempt to click the close frame button. I prefer u ...

What is the proper way to define the properties for a higher-order component that will encompass the Route component from React Router?

I am currently working on a PrivateRoute component that will wrap the Route element from react-router-dom. My goal is to verify if the user has a token and then decide whether to allow or deny access to the destination screen. However, I'm encounterin ...

Design a dynamic div element for banners that adjusts to different screen

Is there a way to create a responsive div similar to the img-responsive class in Bootstrap, but for a div element that changes its height relative to its width when the window size is adjusted? For example, if you look at the slider on this website "", yo ...

execute a C++ application within a web browser using HTML

Recently, I created a captcha program using c++ and sfml. Now, I'm interested in running this program on an HTML page. Can anyone provide guidance on how to accomplish this? ...

Attempting to implement a multi-select input field using AJAX

I am attempting to save multi-select input using ajax in a Laravel application, but I keep encountering the following error: {message: "Function name must be a string", exception: "Error", …} Below is my Blade code: <select class= ...

How challenging is it to transfer a CSS file from one .NET server to another?

Let's break it down: - Our website is constructed using a commercial CMS known as Sitefinity - The structure of the web site is based on .NET - We have both a test server and a live server established for development purposes (HTML, CSS, JavaScript ...

Tips for creating a responsive navigation bar using your own custom CSS styling

While working on a website using bootstrap, I encountered an issue with responsiveness when adjusting the text size and gap of the navigation items. By increasing the size and adding a gap through fs-4 and style="gap: 10vh;", the default small si ...

I have a website hosted on Heroku and I am looking to add a blog feature to it. I initially experimented with Butter CMS, but I found it to be too pricey for my budget. Any suggestions on

I currently have a website running on Heroku with React on the front end and Node.Js on the back end. I want to incorporate a blog into the site, but after exploring ButterCMS, I found the pricing starting at $49 to be too steep for my budget. My goal is ...

Are you in need of a BISON middleware solution for socket.io encoding and decoding?

Is there a method to manipulate the data transmitted by socket.io just before it is sent or received? I was considering implementing something like an express middleware. This way, I could encode the data after the normal .emit() call and before the socket ...

Using TypeScript generics to define function parameters

I'm currently working on opening a typescript method that utilizes generics. The scenario involves an object with different methods, each with specified types for function parameters. const emailTypes = { confirmEmail: generateConfirmEmailOptions, / ...

Concealing the table border with the help of jQuery

I am working with a dynamically created tables in a ASP.NET repeater, where the number of tables can vary depending on the data retrieved from the database. Below is a sample markup along with the CSS and jQuery code. Please note that the tables are dynami ...

Modify the appearance of the datepicker and set the field to be view-only

As a beginner in jquery and the date picker, I'm struggling to change the date format to YYYY-MM-DD and restrict users from typing in the field, allowing only date selection. I have tried various methods without success. Any help or guidance would be ...

Utilizing HTML styling within a label component

The formatting of the HTML is working perfectly in this scenario. The last name is displayed with a font size of 5. lblWelcome.Text = "Welcome:<font size=''5''>" & txtSurname.Text & "</font>" Why is the HTML style ...