The issue of overflowing scroll functionality appears to be malfunctioning

.main-content{
  height: 100%;
  width: 60%;
  min-height: 800px;
  background-color: white;
  border-radius: 5px;
  margin-left: 1%;
  border: solid 1px black;
}

.profile-banner{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 7vw;
  margin-top: 7%;
  background-color: rgba(71, 135, 195, 0.5);
}

.profile-avatar{
  width: 18%;
  margin-right: 3%;
  img{
    width: 100%;
    border: solid white 2px;
  }
}

.profile-username{
  margin-left: 5%;
  font-size: 4vw;
  color: $font-blue;
  font-family: 'Titillium Web', sans-serif;
  -webkit-text-stroke: 1px white;
}

.profile-second-sec{
  margin-top: 8%;
  height: 20vw;
  background-color: blue;
}

.profile-third-sec{
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: 8%;
  height: 30vw;
  background-color: grey;
  overflow-x: scroll;
  white-space: nowrap

}

.profile-image-container{
  display: flex;
  align-items: center;
}
<div class="main-content">
<div class="tab-header font-large">
  <i class="fa fa-user"></i> User profile
</div>
<div class="profile-banner flerowspb">
  <div class="profile-username">
    User profile 
  </div>
  <div class="profile-avatar">
   Avatar image
  </div>
</div>

<div class="profile-second-sec">

</div>

<div class="profile-third-sec">
  >> This is where the images go <<
</div>
</div>

EDIT: included code snippet for reference

I am attempting to create a horizontal scrolling div, but when I add content images, they get resized and squeezed inside the container like this:

The images are being resized to fit within the container, but I want them to be displayed at their original size with the ability to scroll horizontally.

I tried adding "overflow: scroll" but it didn't work as expected.

  .profile-third-sec{
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-top: 8%;
    height: 30vw;
    background-color: $font-grey;
    overflow-x: scroll;

  }

  .profile-image-container{
    display: flex;
    align-items: center;
  }

I thought I understood how to achieve this, but clearly I need some help! Any suggestions would be appreciated.

Thank you

Answer №1

To enhance the image display, you can eliminate the flexbox rules and apply specific properties to the image. Utilizing white-space and overflow attributes should help achieve the desired result.

For instance:

.main-content {
  height: 100%;
  width: 60%;
  min-height: 800px;
  background-color: white;
  border-radius: 5px;
  margin-left: 1%;
  border: solid 1px black;
}

.profile-banner {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 7vw;
  margin-top: 7%;
  background-color: rgba(71, 135, 195, 0.5);
}

.profile-avatar {
  width: 18%;
  margin-right: 3%;
  img {
    width: 100%;
    border: solid white 2px;
  }
}

.profile-username {
  margin-left: 5%;
  font-size: 4vw;
  color: $font-blue;
  font-family: 'Titillium Web', sans-serif;
  -webkit-text-stroke: 1px white;
}

.profile-second-sec {
  margin-top: 8%;
  height: 20vw;
  background-color: blue;
}

.profile-third-sec {
  margin-top: 8%;
  height: 30vw;
  background-color: grey;
  overflow-x: scroll;
  white-space: nowrap
}

.prgile-third-sec img {
  display: block;
  width: 100%;
  height: auto;
}

.profile-image-container {
  display: flex;
  align-items: center;
}
<div class="main-content">
  <div class="tab-header font-large">
    <i class="fa fa-user"></i> User profile
  </div>
  <div class="profile-banner flerowspb">
    <div class="profile-username">
      User profile
    </div>
    <div class="profile-avatar">
      Avatar image
    </div>
  </div>

  <div class="profile-second-sec">

  </div>

  <div class="profile-third-sec">
    <img src="https://unsplash.it/300">
    <img src="https://unsplash.it/300">
    <img src="https://unsplash.it/300">
    <img src="https://unsplash.it/300"></div>
  </div>

Answer №2

When using Flex, the default wrap property can be very helpful. You can experiment with it in your code by applying the following stylesheet.

.classOne {
  display: flex;
  flex-wrap: nowrap;
  overflow: auto;
 -webkit-overflow-scrolling: touch;
 -ms-overflow-style: -ms-autohiding-scrollbar;
}

.classTwo {
  display: flex;
  flex-wrap: nowrap;
}

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

Changing button alignment using CSS to create a new line

Currently, I am working on a React project using Material-UI where I am trying to create a numpad. The code snippet below showcases part of my implementation: // some parts are omitted for conciseness const keys = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0]; ...

Ensuring text is perfectly centered within a div, regardless of its length

In the quest to center text of unknown length within a div, challenges arise. Constraints limit its size to a certain extent, making it unclear whether one or two lines will be needed. As such, traditional methods like line-height are not viable options. A ...

Converting Umbraco Json to a CSS class named "[]"

I'm currently using Umbraco with the data-type grid layout and I am trying to add custom settings (CSS classes) to each row/cell. The results are somewhat working, but I want to improve it. Here's the user interface: https://i.stack.imgur.com/iY ...

Ruby Thin Server: An Unexpected ActionView Template Error

Encountering an issue when trying to deploy my project on Amazon Web Services and accessing the domain. ActionView::Template::Error (Command 'java -jar /home/ubuntu/.rvm/gems/ruby-2.1.10@silk/gems/yui-compressor-0.12.0/lib/yui/../yuicompressor-2.4.8 ...

Positioning the label for a Material-UI text field with an icon adornment when the shrink property is set

https://i.stack.imgur.com/E85yj.png Utilizing Material-UI's TextField, I have an Icon embedded within. The issue arises when the label "Your good name here" overlaps the icon instead of being placed beside it. This problem emerged after I included ...

Stylish Zigzag Border with a Patterned Background

Recently, I've been experimenting with creating a header that features a unique zigzag border. Traditionally, this effect is achieved using images to achieve the desired look. (1) I am curious if there is a way to implement a cross-browser compatible ...

Achieve perfect alignment of an HTML table by positioning it precisely 36 pixels away from the right edge of the window

I'm struggling to achieve a table that is precisely 36px away from both the left and right edges of the browser window, regardless of CSS. While I can easily set the left margin, getting the exact right margin seems impossible as the `margin-right` CS ...

Modify the innerHTML to adjust font size when a button is clicked in Ionic 5, or eliminate any unnecessary spaces

I have been experimenting with changing the font size of a variable in .html when the variable contains whitespace. In my .ts page, I use the following code to remove the whitespace: this.contents = this.sanitizer.bypassSecurityTrustHtml(this.product[&apos ...

Resizing an image within a div with automatic adjustment, centered and aligned to the bottom position

I'm really struggling to understand this concept and not making much progress. I have a background image that automatically scales to fit the window size. In front of it, I want to center an image fixed to the bottom of the page, while still being sca ...

When the span element's height is set to 100%, it does not automatically match the height of its parent div

I have a scenario where I am working with two div elements and a span element in between. The parent div element does not have a defined height, it is calculated based on the content within the div. However, the span element's height is set to 100% ev ...

Creating a draggable element in JavaScript using React

I've been attempting to create a draggable div element, but I'm encountering some perplexing behavior. The code I'm using is directly from w3schools and it functions correctly for them, however, in my implementation, the div always shifts to ...

CSS problem: HTML element moving to the right upon clicking

Currently, I am utilizing a jQuery popup to present additional information to users. The setup involves having a link on the page that triggers the popup to appear from the top. The popup script being used is sourced from CodePen. However, an issue arises ...

What is the best way to add a right-hand side navigation bar without blocking the scrollbar from view?

Take a look at this webpage: I am designing a website that includes a header, a footer, and a central container with left and right navigation bars surrounding a content area. However, I want the scrollbar for the content to appear on the right side of th ...

Customize the appearance of the date input box in MUI KeyboardDatePicker

Currently, I am attempting to customize the appearance of the KeyboardDatePicker component including board color, size, font, and padding. However, none of the methods I have tried seem to be effective. Here is what I have attempted so far: 1 . Utilizing ...

What is the term for the visual display of a product through a photo gallery or slideshow?

Can someone help me identify what the item I'm looking for? You can click on the link to see an example of the product: sephora product example What is the technical term for the section that contains product pictures and slides? Are there any librar ...

carousel/slider must be accessible

I have been searching for hours and still cannot find the perfect carousel/slider that I need. The one at this link is close to what I want, but it becomes inaccessible when JavaScript is disabled in the browser. I am looking for a jquery infinite carous ...

What are some alternative ways to arrange this main navigation bar?

Check out the website, below the map you'll find an unordered list: HTML code: <ul class="play_navigation"> <li class="active"><a href="#" class="barino_story_bottom">The Story</a></li> <li><a href="#" ...

Tips for properly formatting a fixed table header

I'm currently facing an issue with the sticky header style in my data table. I have created a simple Angular component along with a specific directive: sticky.directive.ts @Directive({ selector: '[sticky]' }) export class StickyDirecti ...

Adjust the size of the div menu according to the window's dimensions

Is there a way to make a menu that will resize both the width and height of the window? I've managed to resize the width using %, but for some reason, the height isn't cooperating. I've experimented with max-width/height settings and tried ...

How can I restrict the number of items displayed in each row within a navigation submenu flexbox?

My primary navigation menu has numerous child items, and I want to ensure they remain visually appealing and organized. To achieve this, I am aiming to limit each row of submenu items to only 4. After researching other solutions online, I attempted adding ...