Position the container flush with the left edge and expand it to occupy the entire right side

Can someone help me figure out how to align a carousel with the left side of a container and make the right side stretch to fill the remaining space? Check out the image in the link below for reference. Much appreciated. https://i.sstatic.net/SMlkd.png

Answer №1

To achieve the desired effect, one method involves allowing the gallery element to overflow while preventing scrollbars from appearing on the outer containers main or body

html,
body {
  overflow-x: hidden;
}

.wrapper {
  width: 400px;
  margin: 0 auto;
}

.gallery {
  background: aliceblue;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 10px 0;

  .item {
    flex: 0 0 250px;
    background: cadetblue;
    padding: 10px;
  }
}
<main>
  <div class="wrapper">
    <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla rerum voluptatum ex, dolores reiciendis praesentium, assumenda nam ab tenetur nesciunt fugiat molestias totam quas vel eos debitis amet nihil. Asperiores?
    </p>

    <div class="gallery">
      <div class="item">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sed, id. Aut nulla ab vero corporis cupiditate voluptatem fugiat, deleniti dolores assumenda perferendis facilis delectus officia! Rem maxime repellat quod sunt?
      </div>

      <div class="item">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sed, id. Aut nulla ab vero corporis cupiditate voluptatem fugiat, deleniti dolores assumenda perferendis facilis delectus officia! Rem maxime repellat quod sunt?
      </div>

      <div class="item">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sed, id. Aut nulla ab vero corporis cupiditate voluptatem fugiat, deleniti dolores assumenda perferendis facilis delectus officia! Rem maxime repellat quod sunt?
      </div>

      <div class="item">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sed, id. Aut nulla ab vero corporis cupiditate voluptatem fugiat, deleniti dolores assumenda perferendis facilis delectus officia! Rem maxime repellat quod sunt?
      </div>
    </div>

    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla rerum voluptatum ex, dolores reiciendis praesentium, assumenda nam ab tenetur nesciunt fugiat molestias totam quas vel eos debitis amet nihil. Asperiores?
    </p>
  </div>
</main>

Answer №2

After some work, I was able to finish it with the following CSS:

.content{
    margin-left:calc((100% - 1140px) / 2); /* Setting container width to 1140 */
    display:flex;
    flex-wrap:wrap;
}

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

Removing the current loader element to display the content section: ways to delete the current loader element in order

I'm experiencing an issue with my preloader where it is not fading out to reveal the content. Below is the code snippets for my HTML, JS, and CSS: HTML: <body> <div class="preload" id="preload"></div> <div class="conte ...

CSS class 'nav nav-pills nav-justified' does not stack tabs properly on mobile devices

Currently, I am utilizing the most recent version of Bootstrap within an Angular environment. However, I have encountered an issue where the class "nav nav-pills nav-justified" does not stack the tabs properly when the screen size is reduced below 768px. ...

Using Nativescript to retrieve the current date and time on a physical device

Is it possible to retrieve the current date and time from the device automatically? I'm concerned that if the user disables automatic date and time settings and inputs their own, it could potentially cause my app to crash. Additionally, my app is inte ...

Creating a dynamic multi-level menu within a hamburger menu

Tackling the challenge of creating a hamburger multi-level menu for a web page using CSS has proven to be quite tricky. The main issue I'm encountering is successfully incorporating a sub-menu to make it truly multi-level. Here's the progress I&a ...

Bizarre symbols observed while extracting data from HTML tables produced by Javascript

I am in the process of extracting data from Specifically, my focus is on the "tournament-page-data-results" div within the source code. Upon inspecting the HTML source code, the data does show up, but it appears with a mix of real information and random c ...

How to Place Buttons on the Left, Center, and Right in Bootstrap Framework

I'm currently working on developing some pages using bootstrap. In the form at the bottom, I have three buttons - Save, Cancel, and Commit. The issue I'm facing is that while the left and right buttons are perfectly aligned, the Cancel button is ...

Do not proceed if the process has encountered a failure

Using PHP code, I have created a way for people to get in touch with me and share their opinions. Here is the PHP code snippet: <?php $to = '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef9b868c848a9bc19d869b8e988a8 ...

Incorporated asynchronous functionality, struggling to integrate it into the code

Previously, I used to utilize the following code for handling state: //get state MyClass.prototype.getState = function(key) { var value; switch(this._options.type){ case "cookie": value = $.cookie(key); ...

What is the correct way to utilize async/await in a React render function?

Although I am quite familiar with using async await in back end development with nodejs, I recently encountered a scenario where I needed to apply it on the front end. The task involves receiving an array of objects containing the latitude and longitude ( ...

Transmitting data to a PHP script via AJAX and receiving a delayed response is not ideal for my needs

I am currently working on a contact page and have set it up to send a response if an invalid email is entered. However, the current code sends back an error message if a field is missing or left blank before clicking send. You can view the page at I still ...

Preventing the entire HTML page from loading in the registration form on ASP.NET: Tips and tricks

I am currently developing an ASP.NET web application that includes a registration form. However, I am facing an issue where every time a user enters their Username or Email, the entire first_home page reloads. How can I prevent the entire page from reloadi ...

Problem with the hover functionality of the <li> tag

I'm having an issue with applying the hover property to the li element in the sidebar. The hover effect works, but the icon tag is not showing the hover effect. I want the icon to also show the hover effect along with the li's hover effect. Here ...

File or directory does not exist: ENOENT error occurred while trying to scan 'pages'

Having trouble adding a sitemap to my nextjs app - when I go to http://localhost:3000/sitemap.xml, I get this error: Error: ENOENT: no such file or directory, scandir 'pages' https://i.sstatic.net/cxuvB.png The code in pages/sitemap.xml.js is a ...

Transforming pure JavaScript code into jQuery code

Currently, I am attempting to add JSON data from the last.fm API into my project. Throughout this process, I have been using the alert() function at various points to confirm that the API data is being correctly parsed. However, it appears that the getEl ...

What is the process of programmatically sorting a column in a Material UI DataGrid?

Hey there! I'm currently working on a DataGrid that has a column with a custom header, specifically a Select option. My goal is to have the column sorted in descending order every time a user selects an option from the dropdown menu. renderHeader: (pa ...

Inexperienced with Bootstrap/CSS: Cannot open dropdown by clicking (CDN properly installed)

I am having trouble getting my Bootstrap dropdown to toggle correctly, despite placing the JS script last. I have checked multiple resources and it was suggested that CDN may not have been imported correctly. I have also tested this on different browsers w ...

Beginning the process of setting up information windows for map markers with the help

As I work on dynamically adding info windows to Google Maps markers from a JSON array received from the server, I find myself grappling with Javascript's handling of variables and scope. One attempt involved this code snippet: $.getJSON("server", fu ...

Why does changing the order of layers in Kinetic.JS affect the color of my shapes?

Currently experimenting with Kinetic.JS, I managed to create a UFO-like shape using two parts - a red hull and a grey disc. Check out the demo on JSBin My question is: why does the color of the disc change from grey to red when I rearrange the shape orde ...

Elements within the div are overlapping each other

Despite adding margin, my h3 tag and p tag in a div keep overlapping. .title { margin: 0 0 26px; width: 335px; height: 28px; font-size: 24px; font-stretch: normal; font-style: normal; line-height: 36px; letter-spacing: 0; text-align: c ...

Type in data into the database in real-time

Can someone help me with inserting data into a database while typing values in a textbox? My AJAX code doesn't seem to be working and I'm not getting any errors. Please assist me as soon as possible. Here is my AJAX code: var userid = '#u ...