The horizontal overflow in CSS is ineffective

I am currently working on a project where I need to place multiple divs (represented by black blocks) within a container (depicted as a blue block). The challenge is to fit in as many divs as possible within the container, which has a variable width and different sizes on each screen.

Currently, the setup I have (shown as "1" in the image) is functional. However, I am facing an issue with using Bootstrap popover throughout the site. The overflow in the container prevents the popover from appearing. If I remove the overflow property ("2" in the image), all the divs move to a new line, which is not the desired outcome. My goal is to hide any divs that do not fit within the container without requiring scrolling.

The ideal solution would look similar to the arrangement shown as "3" in the image.

https://i.sstatic.net/H1Evu.png

Below are snippets of my code:

// CSS
.content-bar{
        max-width:100%;
        height: 3.5em;
        white-space:nowrap;
        display: inline-block;
        overflow-x: hidden;
        overflow-y: visible;
}

.photo-bar{
        width: 2.5em;
        height: 3.5em;
        margin-right: -.55em;
        padding: 0;
        display: inline-block;
        white-space: normal;                
}

// JS
<div class="content-bar">
        <div class="photo-bar" ng-repeat="...">                    
             // image goes here
        </div>
</div>

Answer №1

In order to make it scrollable, you must include the following CSS property:

overflow-x: scroll;

Answer №2

Option 1: To resolve the issue with the popup not appearing as expected, you can simply remove the overflow properties from your styles. When applying these properties inline, the popup will display correctly. See the Code snippet below for reference.

Option 2: If applicable to your situation: Consider using overflow hidden and adding padding-top to the ".content-bar" class. The padding top should match the height of the popup.

// CSS
.content-bar{
  max-width: 100%;
  height: 3.5em;
  white-space: nowrap;
  display: block;
  overflow-x: scroll;
  /*overflow-y: visible;*/
}
.photo-bar {
  width: 2.5em;
  height: 3.5em;
  margin-right: -.55em;
  padding: 5px;
  display: inline-block;
  white-space: normal;
  background-color: lightblue;
  border: 1px solid;
}
<div class="content-bar" style="white-space: nowrap;overflow-x: scroll;">
  <div class="photo-bar">
    <img src="http://placehold.it/50x10" />
  </div>
  <!-- More photo-bars here -->

</div>

Answer №3

It seems that what you need is overflow-x: scroll;

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

Animating Angular for particular conditions

My goal is to create unique animations for specific state changes in my AngularJS app. I found inspiration from this tutorial: https://scotch.io/tutorials/animating-angularjs-apps-ngview, which works well. However, I am aiming for the following animations: ...

Is there a way to configure gulp-sass to compile the actual bootstrap CSS styles instead of just echoing the import statement?

I recently embarked on a project where I wanted to utilize the Sass bootstrap source (.SCSS), apply some customizations (through another .SCSS file), and generate a CSS output. To achieve this, I decided to employ Gulp in VS2019 with gulp-sass. After goin ...

Tips for making an image fill the screen while keeping space for content underneath

Upon loading the page, I would like my image to fit the size of the screen. While I've achieved this, all other text now appears underneath the image rather than below it (I hope that clarifies things). .main { position: absolute; width: 100%; ...

Running a CSS keyframes animation can be achieved by removing the class associated with it

Is there a way to reverse the CSS animation when a class is removed? I'm trying to achieve this on my simple example here: https://codepen.io/MichaelRydl/pen/MWPvxex - How can I make the animation play in reverse when clicking the button that removes ...

Navigating to the designated row within the HTML table even with a scrollbar present

I am working with a table where the selected row is highlighted when a user clicks on it. In another panel, there is a map displaying all employees. Each row in the table has a unique ID and clicking on an employee's image on the map highlights their ...

Verifying the invocation of a callback function through the use of $rootScope.$broadcast and $scope.$on

I have been testing to see if a callback was called in my controller. Controller (function () { 'use strict'; angular .module('GeoDashboard') .controller('CiudadCtrl', CiudadCtrl); CiudadCtrl.$i ...

Positioning three squares with the same class adjacent to each other by utilizing absolute positioning

I've been pondering whether it's possible to align elements with the same class and position: absolute next to each other. After an hour of experimenting, I discovered a solution: http://jsfiddle.net/hv01ad1r/1/ However, when attempting to use d ...

Why isn't the float left property working as expected?

Why won't my image float to the left? I'm using a class called align-left with float: left but it's not working. You can see the live version at - (check out the review grid halfway down under the heading 'High customer satisfaction r ...

Steps to begin again an Ionic application on IOS operating system

Currently, I am in the process of developing an Ionic application for both Android and IOS platforms. One challenge I am facing is that if any errors occur either on the server side or client side, the app automatically restarts. For Android, I have succe ...

The collapsible toggle feature is currently not working as intended

I have tried looking for solutions but have not been successful. My apologies for asking what may seem like a simple question. The toggle button is not expanding to show the menu items when clicked. It works fine on the "home" page but not on the linked pa ...

Breaking information into sections to be spread across various columns

Scenario: Your CMS allows users to control the content displayed, which includes multiple columns with links underneath. Here is an example layout: Column name link1 link2 link3 link4 link5 link6 liiiiiiiiiiiiiiiiiink7 link8 liiiink9 liiiiiiink10 ...

Utilizing Filters to Dynamically Highlight and Unhighlight HTML in Angular

Currently, I am experimenting with creating a series of filters that can dynamically highlight and remove highlighting from generated HTML: Highlight filter: app.filter('highlight', function ($sce) { return function (str, termsToHighlight) ...

Using Angular to retrieve JSON data from a static file

Currently, I am attempting to implement this AngularJS example from a tutorial on Login Tutorial Example. Instead of storing the username and password as simple strings, I am trying to retrieve them from a local file. I understand that this may not be the ...

When implementing CSS, the background image in the header section of my webpage is not visible to me

I'm currently working on a basic webpage and encountering an issue with setting an image as the background for my header section. Despite using what I believe to be the correct code in the CSS section, specifying the right path and file name for the i ...

Pattern that determines the validity of a password

My current password validation pattern does not allow white space and requires at least 6 characters: /[^\s]+.{6,}/; I specifically need 6 characters that are anything except a space. However, this pattern is not functioning as expected. const ...

Arranging Bootstrap buttons in a clean row

How can I add two nav buttons "register" and "sign in" to the top right of my navigation bar, and include a separate button "request a demo" below them without displacing the first two buttons? I am currently using a br tag to push the third button down ...

List that scrolls with a stationary button

I am working on an interface that includes a button with a dropdown list. Here is an example: <a href="https://jsfiddle.net/DTcHh/16589/" rel="nofollow">jsfiddle</a> While the list is scrollable, I am looking to add a fixed button at the botto ...

Creating a customized list item design using Bootstrap 3 and incorporating div elements

I have designed a custom li element with Bootstrap 3, but I am looking to achieve something specific. . Here is my current setup- HTML- <ul class="list-group"> <li class="list-group-item" id="baal"> <div style="display: inlin ...

Trigger an Angular controller within Foundation's reveal modal

Trying to implement a form using foundation's reveal modal, I want to incorporate an angular controller within the form for ajax form submission instead of the default post/refresh behavior. This is my primary view: <html lang="es" ng-app="crm"&g ...

Exploring the AngularJS and Laravel fusion: Wizard navigation

I am struggling with building a multi-form/wizard step navigation using ng-switch to create the steps. Here's the code snippet I'm working on: HTML: <div ng-controller="stepCtrl"> <div ng-switch="step"> <div ng-switch-when="1" ...