Responsive layout with two independent columns, one of which has an overflow feature

With Angular material, creating a responsive layout is simple. Currently, I have set up 2 columns with independent overflow like in this example: http://jsfiddle.net/2f6qscrp/227/. However, the issue lies in responsiveness; on mobile, the columns stack below each other and on larger devices, they align to the right/left correctly but still maintain separate overflows instead of creating one main overflow that encompasses both columns. Is there a way to address this problem?

<div ng-app="home" ng-controller="MainCtrl" class="scroll">
  <div layout="column" layout-gt-sm="row" class="scroll">
    <div flex class="blue">
      [Content for blue column goes here]
    </div>
    <div flex class="red">
      [Content for red column goes here]
    </div>
  </div>
</div>

CSS:

.scroll {
   min-height: 100%;
   height:100%;
}

.blue {
  background-color: #0D47A1;
  color: #fff;
  min-height: 100%;
  overflow-y: scroll;
  height:100%;
}

.red {
  background-color: #B71C1C;
  color: #fff;
  min-height: 100%;
  overflow-y: scroll;
  height:100%;
}

Thank you.

Answer №1

Check out this solution

.scroll {
   min-height: 100%;
  height:100%;
}

.blue {
  background-color: #0D47A1;
  color: #fff;
  min-height: 100%;
  overflow-y: scroll;
  height:100%;
}

.red {
  background-color: #B71C1C;
  color: #fff;
  min-height: 100%;
  overflow-y: scroll;
  height:100%;
}

@media (max-width:1600px) {
  .blue, .red, .scroll {
    height: auto;
    min-height: auto;
  }
}

To see a live demo, click here - http://jsfiddle.net/2f6qscrp/228/

Answer №2

So, based on my understanding:

  • You're looking for larger screens to display two columns (red and blue in your design), each capable of scrolling independently vertically if the content overflows.
  • On smaller screens like mobile devices, you want the two columns to merge into a single scrollable column.

To achieve this, you can utilize media queries. Here's an example:

@media (max-width:600px) {
   .red,
   .blue { width: 100%; }
}

Incorporating this code snippet into your CSS in JSFiddle should produce the desired outcome. Feel free to adjust the max-width value as necessary, keeping in mind the content and layout's responsiveness.

(Just a heads up: I selected 600px as a generic mobile threshold in this demonstration. Customize it according to your specific requirements and how the design behaves in real-world scenarios)

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

Prevent textArea from reducing empty spaces

I am facing an issue with my TextEdit application set to Plain Text mode. When I copy and paste text from TextEdit into a textarea within an HTML form, the multiple spaces get shrunk. How can I prevent the textarea from altering the spacing in the text? T ...

<ol><li>Arranges elements in a peculiar way if the image is aligned to the left</li></ol>

Explore this comprehensive presentation on combining PDFs online. In this blog post, I have encountered two instances of <ol><li> formatting. The first one is styled properly using the following CSS: .post_content ul, .post_content ol ...

The CSS no-repeat background image property seems to be functioning properly only in the Firefox

.myclass{ background-image: url('http://image.flaticon.com/icons/svg/34/34164.svg'); background-repeat: no-repeat; background-size:contain; background-position: 1.5%; } Every row (tr) in my table is assigned the class myclass: <tr cl ...

Issues with Videojs Responsive Lightbox Functionality

I am looking for a solution to display VideoJS in a lightbox while keeping it responsive. I came across this helpful code snippet: https://github.com/rudkovskyi/videojs_popup. It seemed perfect until I tried using it with the latest version of Videojs and ...

Configuring a fixed menu in one direction using jQuery

Currently, I have a left-sided "fixed" menu bar on my website that should follow the user's scroll down the page. In my attempt to achieve this functionality, I have experimented with two different methods: one utilizing CSS and the other using jQuery ...

Is it possible in CSS to ensure consistent width across various platforms and devices, regardless of their physical dimensions?

When it comes to altering the width (or any other properties) of an element using @media queries, there are multiple approaches available. One option is to utilize aspect pixel ratio, device width, and height. Find out more at https://developer.mozilla.or ...

What is the best way to customize a component in a view?

<template> <div class="about"> <Header /> <h1>Welcome to the dashboard page</h1> </div> </template> <script> import Header from "../components/layout/Header.vue"; export default { name: "dashb ...

Determine whether AngularJS directive method binding automatically defaults to angular.noop

In my directive, I am passing a function to a plugin which will use it with a specified value. Let's simplify things by ignoring data changes: angular.module('some.directives', []) .directive('myDirective', [, function () { ...

What could be the reason behind this AngularJS todo application evaluating an if statement only once?

When using the function $scope.addTodo(), I encountered a strange behavior in my browser. It seems that the if statement is only evaluated on the first entry into the $scope.todos array. Upon creating a single todo, I am able to add blank todos even though ...

Having trouble with printing the $length variable? Attempting to input data from duplicated forms

I have unique code presented below. In my HTML input tags, I have declared arrays named field, title[], first_name[], last_name[], email_address[], twitter_handle[]. These arrays were declared for form cloning purposes handled in a .js file. Now, my goal i ...

Exclusive Checkbox Update

My code is causing me some trouble. When I click the update button, I want to only display the checked fields from the checkboxes on the redirected page. Below, I will share the code from the initial page, followed by the code from the second page where t ...

Angular Material's Material Button exhibits varying behavior when the text on the button is clicked

Let's analyze the code snippet below: HTML: <button mat-flat-button id="test" (click)="toggle($event)">Click me!</button> Component: toggle(event) { let id: string = (event.target as Element).id; console.log(id) console.log(event ...

Omit the tag from the submission section

Currently, I am utilizing a <p> tag as a submit button/area by setting a specific id in jquery. <p id="xyz"></p> My requirement is to insert an input field inside this <p> tag to include a particular value that will be submitted u ...

Reorganize the sequence of rows in ng-table using AngularJS

I am looking to add a feature in my ng-table where users can switch between ascending, descending, and the original row order when sorting. Currently, I have enabled sorting using $scope.tableParams.sorting(), but it only switches between ascending and des ...

Disabling $routeprovider while implementing bootstrap

I am encountering an issue with my normal routeprovider code. In a specific section of my HTML, I have some Twitter Bootstrap expand/collapse sections which inadvertently trigger the routeprovider when clicked. Is there a way to prevent this from happening ...

allowing the addition of bootstrap glyphicons to input field

I am having difficulty adding a Bootstrap glyphicon to my form. <form role="form"> <div class="form-group has-feedback"> <label class="control-label">Username</label> <input type="text" class="form-control" placeholder= ...

Learn the art of incorporating items and attributes into HTML through JavaScript or jQuery by extracting information from a csv or json file

As someone who is not a web developer, I am seeking to enhance the maintainability of the code below. My idea is to simplify the process using an appropriate method. I aim to dynamically inject content and attributes into an HTML file by utilizing either ...

Guide on displaying JSON information upon clicking using JavaScript

I'm having difficulty writing the logic for this code. I have extracted data from a vast API. The current code fetches all program titles (some may be repeated) and compares them with an array of late night shows, then displays them once in their own ...

How can I determine the days that have been selected based on the sum of their values?

I am working with a list of checkboxes that represent the days of the week, each associated with a specific numerical value. The values assigned to the weekdays are [1,2,4,8,16,32,64]. <label class="m-checkbox"> <input type="checkbox" name="s ...

Struggling to achieve the desired layout in the navigation code using CSS Grid. I am aiming for it to occupy the entire width of the screen

I'm facing an issue with customizing my HTML layout using grids. I want my nav element to occupy the entire available width. Below is my current code: header { text-align: center; grid-area: header; border: solid; } #nav1 { text-de ...