Freeze backdrop - remain stationary while sections enlarge

My webpage has a split background - blue at the top and white at the bottom. Here is the CSS style I am using to achieve this:

//accordion - changes colour on open / close

var selectIds = $('#panel1,#panel2,#panel3');
$(function($) {
  selectIds.on('show.bs.collapse hidden.bs.collapse', function() {
    $(this).prev().find('.fa').toggleClass('fa-plus fa-minus');
  });
  $(".panel-heading").find("a[data-toggle=collapse]").on('click', function() {
    if ($(this).hasClass('collapsed')) {
      $(this).closest('.panel-group').find('.panel-default').removeClass('open');
      $(this).closest('.panel-default').addClass('open');
    } else {
      $(this).closest('.panel-default').removeClass('open');
    }
  });
});
.gradient {
  background: -webkit-repeating-linear-gradient(#74ABDD, #74ABDD 49.9%, #498DCB 50.1%, #498DCB 100%);
  /* more properties */
}
.split {
  width: 100%;
  /* other properties */
}
/* more CSS code */

<section class="page-section page-section-md split gradient">
  <div class="row">
    <div class="col-md-2">
      <h4 class="heading-responsive text-white">
               Welcome
            </h4>
    </div>

    <!-- more HTML code -->

</section>

However, when I expand the Bootstrap panels inside the background, the background also moves (i.e., the blue extends lower as I open panels). How can I make the colors fixed regardless of the background size?

This link provides a good reference for achieving a fixed background when panels are expanded.

I believe this is a simple fix that I am overlooking. Thank you in advance for your assistance!

Answer №1

The height of the blue top is determined by the background gradient set in the '.gradient' class (currently with the top 49.9% as blue and bottom 50.1% as white). To achieve this effect, you can assign a height of 100vh and overflow: scroll to your .split class.

.split {
  width: 100%;
  height: 100vh;
  overflow: scroll;
  padding: 2% 5% 5% 5%;
}

For a live example, check out this fiddle: https://jsfiddle.net/wietsedevries/bk4ogp38/3/

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

Issue with dropdown menu items inheriting CSS border from parent menu item

I am facing an issue with the drop-down menu I created, as some of the sub menu items are inheriting CSS properties from the parent menu item. In particular, the sub menu items are picking up the blue border from the parent and the light blue background c ...

Retrieving the latest data iteration from the parent component

Is there a way to access the current data iteration from the template? I also need to obtain specific id's from the iterated elements. <template x-for="(datas, idx) in data"> <tr x-bind:class="idx % 2 == 0 ? &a ...

Troubleshooting problem with strokeRect on canvas following a CSS transform rotate(90deg)

English is not my strong suit, so please bear with me. Let me outline the issue I'm currently grappling with. I'm in the process of developing a function that allows users to draw a rectangle on a canvas using their mouse (specifically, using t ...

Hyperlinks on Image Map fail to function properly on IE and Firefox browsers

I have successfully implemented an image map on this webpage: to open links in Chrome, however, I am encountering issues with IE and Firefox. Initially, I added "#" to the image map names as a potential solution, but that did not resolve the problem. The ...

What causes the excess spacing in flexbox containers?

Is there a way to remove the padding around the container and between the two columns? I attempted setting margin and padding to 0, but it was not successful. https://i.sstatic.net/i5XJJ.jpg body, html { width: 100%; height: 100%; } main { disp ...

Is it possible to create this design using Masonry?

https://i.sstatic.net/NFszG.png I have been attempting to create a grid layout like so: .grid { width: 99%; border: 1px solid #ccc; } .grid a, .grid .grid-sizer { display: inline-block; width: 20%; padding-bottom: 20%; background-size: cover; ...

Executing Basic Calculations Instantly with Live Data in Qualtrics

I am encountering an issue with displaying the values on a slider in Qualtrics. I need to show the value where the respondent has placed the handle, as well as the complementary value from the other end of the scale. For example, if the user has chosen 55, ...

Press the Concealed Button Enclosed in a div Using Selenium with Python

Currently, I am in the process of automating the login on the Workday portal by utilizing Chrome WebDriver in Selenium. My main challenge lies in figuring out how to click on a hidden sign-in button with the following properties: <div class="css-1s ...

Is there a way to align text with a certain element and ensure that it remains in place regardless of the screen size?

I need the word "social" to remain in line with the black bars, both on regular devices and mobiles. Although in bootstrap/html it may not align perfectly, it still stays close to the black bars. See example here Here is the code. Even though I can adjus ...

Is there a way to stack multiple divs on top of each other in my HTML login page?

Below is the HTML code for my form: <div style="display:block; margin:0 auto;"> <h2>Welcome</h2> </div> <div id="box"> <div id="box2"> <p id="pid"><b>Em ...

Responsive design with Bootstrap 4's column grid system

Currently, we are striving to create a layout that resembles this design. However, I am facing difficulties in making it responsive. Can anyone offer some guidance? Should we solely incorporate col-* classes? Additionally, we are restricted from setting s ...

Loading large content using jQuery's .html() method

After experimenting with the jQuery .html() function, I've noticed that it struggles to handle large amounts of text. You can see an example of this issue. Fortunately, a much simpler test case works perfectly fine. While I understand that including ...

Shifting Elements - Navigation triggers subtle movements in CSS styles as you move across pages

I've noticed a strange issue on my website where certain elements seem to be shifting slightly when navigating between different pages. Here's a quick video clip demonstrating the problem. It appears that these elements are not staying static as ...

Designing a layout that adapts to different screen sizes, utilizing nested div elements

I'm currently working on creating a responsive layout for my website, but I started the project without one and now my basic template has major flaws. How can I create a template like this picture where the divs adjust as the browser viewport size cha ...

CSS Navigation drop-down menu experiences a shaking problem when the mouse hovers between the first and second link

Hey there, I'm experiencing a strange issue with my navigation bar. When hovering the mouse between the first drop-down link and the second drop-down link, a strange jitter occurs. Can someone provide assistance in resolving this issue? You can witn ...

How can JavaScript dynamically assign onclick functions with dynamic parameters?

Here's a piece of code I am working with: document.getElementById('img'+i).onclick = function(){popup_show('popup',array_msg[i]+'|||'+date('Y-m-d',strtotime(lec_date))+'-==-'+str_view_forConflict, &ap ...

Error encountered in angular.forEach syntax

Can someone help me figure out why my array sum calculation using angular.foreach is resulting in a "syntax error" message? I believe my syntax is correct, as indicated by var sum += value.fare;. Any insights on why this error occurs would be appreciated. ...

Position the text on the left side while also centering it within my div

I am attempting to center align some links within my div, while also ensuring that the text of the links is aligned to the left. However, I have been unsuccessful in achieving this. I can either align them to the left or center, but not both simultaneousl ...

Showcase CSS button within Outlook

After creating a CSS gradient button using Button Maker, I encountered an issue with Outlook not displaying it properly due to their CSS restrictions. As a result, I am looking to have a simpler button design for Outlook without success in filling the back ...

Unexpected behavior in Visual Studio's handling of C++ exceptions

After compiling my Qt application in the release configuration, everything runs smoothly when I perform operation X. However, switching to debug configuration and running without debugging still yields positive results. The issue arises when attempting to ...