Divide the Ionic Page into two vertical sections, with the second section designed to be scrollable and constrained in height

In my IONIC project, I'm working on dividing a page into two vertical sections. The first section features a responsive YouTube iframe while the second section contains a list of items. Together, these two divs should fill up the total height of the page.

I've successfully made the YouTube video iframe responsive, but now I'm facing an issue with adjusting the height of the items DIV to occupy the remaining space in the ion-content (the view page). I've tried various solutions without any luck! Is there a way to dynamically calculate and adjust the height of the items DIV so it becomes scrollable? It scrolls perfectly when the height is specified explicitly, but not when left undefined. Any suggestions or help would be greatly appreciated. Thank you.

HTML

<ion-content scroll="false">
  <!-- Video Wrapper -->
  <div class="videoDiv">
      <div class="videoWrapper">
        <div class="videoWrapperIframe">
          <iframe width="560" height="315" src="https://www.youtube.com/embed/-v2ZDYMu1Rc" frameborder="0" allowfullscreen></iframe> 
        </div>
      </div>
  </div>
  <!-- Item Wrapper -->
  <div class="itemWrapper">
    <div class="itemWrapperItem">
      <ion-scroll delegate-handle="item" direction="y">
          <ol class="list">
          <li class="item" ng-repeat="item in items">
          {{item.id}}
          </li>
         </ol>
      </ion-scroll>
    </div>
  </div>
</ion-content>

CSS

.videoDiv {
  display:block; 
  max-width: 400px; 
  margin-right: auto; 
  margin-left:auto;
}
.videoWrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  padding-top: 25px;
  height: 0;
  background-color:#ededed;
}
.videoWrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.itemWrapper {
  position: relative;
  height: 100%;
  display:block; 
  max-width: 600px; 
  margin-right: auto; 
  margin-left:auto; 
   background-color:red;
}
.itemWrapperItem {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

You can find the code on Code Pen at https://codepen.io/codingSober/pen/PjWxJy

Answer №1

It's no secret that your code is quite messy with unnecessary HTML tags and CSS rules scattered around.

While I can't clean up everything, here is a revised version of the HTML + CSS that might suit your needs:

<ion-view view-title="Live Now" hide-back-button="false">
  <ion-nav-buttons side="left">
    <button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
  </ion-nav-buttons>
  <ion-content scroll="false">
    <!--  video wrapper -->
    <div class="videoDiv">
        <div class="videoWrapper">
          <div class="videoWrapperIframe">
            <iframe width="560" height="315" src="https://www.youtube.com/embed/-v2ZDYMu1Rc" frameborder="0" allowfullscreen></iframe> 
          </div>
        </div>
    </div>
    <!--  item wrapper -->
    <div class="itamWrapper">
        <ion-scroll delegate-handle="item" direction="y">
            <ol class="list">
            <li class="item" ng-repeat="item in items">
            {{item.id}}
            </li>
           </ol>
        </ion-scroll>
    </div>
  </ion-content>
</ion-view>
.videoDiv {
  display:block; 
  max-width: 400px; 
  margin-right: auto; 
  margin-left:auto;
}
.videoWrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  padding-top: 25px;
  height: 0;
  background-color:#ededed;
}
.videoWrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

ion-content {
  max-height: 100vw;
}

ion-scroll {
  max-width: 600px;
  margin-right: auto; 
  margin-left: auto; 
}

.itamWrapper {
  background-color: red;
}

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

Utilizing a Bootstrap column design with two columns in place - one column set at a fixed width while the second column stretches across the remaining

Need help with adjusting two columns on a webpage? The right column is fixed at 300px width, while the left column should take up the remaining space. Using flex works well, but when adding a responsive ad to the left column, it extends beyond the availabl ...

Scrolling horizontally through content of unspecified width

Imagine having a content div displaying a long line of text. I want this content to be enclosed within a wrapper div that has a fixed height and the ability to horizontally scroll if the content exceeds the width of the wrapper div. Here are two possible ...

What could be causing the calendar icon to not display in the table cell?

I've been working with the Bootstrap date picker inside a table, and I'm having trouble getting the date picker icon to display using the fas fa-calendar-alt css class. <td> <input type="text" id="expirydate{{$index}} ...

Issue encountered while determining the specificity of a CSS selector involving pseudo-classes

As I delved into a tutorial on MDN, an intriguing code snippet caught my attention: /* weight: 0015 */ div div li:nth-child(2) a:hover { border: 10px solid black; } An unanswered question lingers in my mind: Why does this rule's specificity displa ...

Updating the class of a div based on a checkbox being checked or unchecked

I am attempting to apply the "isChecked" class to the parent div when a checkbox is checked, using the ngClass directive. Here is the HTML: <div ng-class="{isChecked: (isChecked_1 == 'true')}"> <input type="checkbox" id="check_ ...

Having trouble with Bootstrap form-inline stacking issue, any tips on how to stop them from stacking?

I've created a simple test navbar with a search input box and search button using the Bootstrap class form-inline. However, the search button is appearing below the search input, even though there is enough space available. You can view the codepen he ...

Adjusting the position of an image on a webpage as the user scrolls

Looking to add some flair to your website by making an image slide to a specific spot when you scroll? Imagine the page loading with the image sliding elegantly to the left, then as you start scrolling, it smoothly transitions to the center or bottom of th ...

Does Blazorise support the Material .figure-is-16x16 class?

While Blazorise supports the .figure-is-16x16 class, I have noticed that when using it in Material, it does not work by default. I am curious if the Material version of Blazorise supports this class or if there is another related class available. Current ...

Seamlessly adaptive HTML5 video playback

Has anyone figured out how to make an HTML5 video in an absolutely positioned <video> element resize to fit the window width and height without ever getting cropped? Many solutions I've come across rely on using the <iframe> tag, which is ...

Styling with CSS to ensure divs are displayed in two rows

Check out this example I found: https://jsfiddle.net/n3qs0wke/ .wrapper { max-width: 600px; border: 1px solid #333; } .big-div { min-width: 212px; min-height: 212px; max-width: 212px; max-height: 212px; display: inline-flex; ...

What steps are needed to achieve the hover effect on the portfolio page?

Looking to add a unique hover effect to my homepage design. Here's an example of what I'm envisioning: https://i.sstatic.net/Sx5Ge.jpg Can someone help troubleshoot my code? It's not quite working as intended. .stage_wrapper { margin ...

Creating a loading animation using HTML and CSS for textual content

I came across a website that had a unique text loading effect, but despite my efforts, I couldn't find what it's called. Effect: https://i.stack.imgur.com/NyaSN.png Is there any plugin or CSS file available for this effect, similar to Bootstra ...

The options in the form select dropdown are not correctly positioned

I am new to using Jquery. I am attempting to create a submit form with a select option in it. However, the drop-down options are not displaying correctly. They appear slightly above and to the left of where they should be.https://i.sstatic.net/xZecM.png I ...

Using a CSS Module Class as a Variable in NextJS

Apologies in advance if I miss any details - this marks my debut post on Stack Overflow. The main objective of the function is to operate my hamburger menu, either opening or closing it. I have shared a snapshot of the JSX file pertaining to this issue: N ...

Javascript/jQuery for enlarging and shrinking a div

Struggling with a function I'm implementing for a website. My goal is to move and expand a div upon button click, with the text on the button changing to "close". When the close button is clicked, the div should return to its original position. I&apo ...

I haven't quite reached success yet, but I am working on getting my slideshow to display on my local server

My homepage is fully loading, but the slideshow feature is not functioning correctly. I have a file called slide.js in my /lib directory that I am trying to integrate into my homepage. The images are referenced properly and working, but they are not displa ...

utilize the "li" element to function as a clickable button

My HTML code contains ul elements, as shown below: <ul class="nav" id="loadCategories"> <li class="sub-menu"><a href="#">Search by category</a> <ul class=""> <li><a href="#">Food</a></li> ...

Images are suddenly encircled by a mysterious border

On my wordpress website, I encountered a strange issue with some photos. Specifically, an image of a cross in a circle is getting a weird border around it, but only on certain resolutions (such as width:1506). Despite inspecting the element, I couldn' ...

I am currently experiencing an issue where the list items bullets (<ul>) and numbers (<o>) are not displaying correctly on my webpage, even after using the overflow-x: hidden

I am facing a challenge with my web page where the list items are not displaying the usual dots and numbers next to them. Interestingly, when I remove the overflow-x: hidden; property in my CSS, the list item numbers and dots show up immediately, although ...

Making adjustments to a Jquery data attribute can have a direct impact on CSS

My CSS is using a data attribute, but when I try to change it with jQuery, the change is not reflected on the screen or in the DOM. $('#new-1').data('count', 5); .fa-stack[data-count]:after { position: absolute; right: -20%; to ...