Foundation 6 off-canvas-menu does not conceal the page that is currently visible to the user

I am currently working on a small viewport off-canvas menu using Foundation 6, but I am having trouble making it overlap the entire visible page area. The right-hand side underneath the off-canvas menu does not have background opacity.

https://i.sstatic.net/GKA4i.jpg

To see this issue in action, simply resize your browser viewport width to less than 640px (small viewport) and click on the burger icon at the top left.

link to website

Is there a way to fill the entire space with a transparent black color instead of just the upper part?

Answer №1

It seems like this is intentional, but there are definitely some bugs present.

When the off-canvas menu is opened, the grey overlay's parent expands to cover 100% of the screen height. However, because the content outside of the viewport is not visible, it may appear that everything is being covered. To address this, you can adjust the height of the wrapper to 'auto' or remove the 100% value for height entirely. Keep in mind that by doing so, all content within the viewport will scroll, not just the off-canvas menu contents.

// Make sure to apply the height override to this element
<div class="off-canvas-wrapper-inner is-off-canvas-open is-open-left" data-off-canvas-wrapper="">...</div>

.off-canvas-wrapper, .off-canvas-wrapper-inner {
    height: 100% <-- consider removing this, overriding it, or setting it to 'auto'.
}

Answer №2

By utilizing Javascript, you have the ability to monitor the opened.zf.offcanvas event and manually incorporate a grey overlay to the element that contains the off-canvas-content class. On the other hand, watch for the closed.zf.offcanvas event and eliminate the added CSS when triggered.

Referencing the code example provided in the Foundation documentation:

Using HTML:

        <!-- Close button -->
        <button class="close-button" aria-label="Close menu" type="button" data-close>
          <span aria-hidden="true">&times;</span>
        </button>

        <!-- Menu -->
        <ul class="vertical menu">
          <li><a href="#">Foundation</a></li>
          <li><a href="#">Dot</a></li>
          <li><a href="#">ZURB</a></li>
          <li><a href="#">Com</a></li>
          <li><a href="#">Slash</a></li>
          <li><a href="#">Sites</a></li>
        </ul>

      </div>

      <div class="off-canvas-content" data-off-canvas-content>
        <!-- Page content -->
      </div>
    </div>
  </div>
</body>

Then:

$('.off-canvas-wrapper').on('opened.zf.offcanvas', function() {
  $('.off-canvas-content').addClass('grey-out');
});
$('.off-canvas-wrapper').on('closed.zf.offcanvas', function() {
  $('.off-canvas-content').removeClass('grey-out');
});

grey-out class:

.grey-out {
  background: rgba(60,60,60,0.75) !important;
  z-index: 1000;
}

This has not been tested but it illustrates the concept.

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

challenges encountered when saving a getjson request as a variable

I am experiencing difficulties in retrieving a variable from a getJSON() request. The issue lies within the following three functions: function getPcLatitude() { // onchange var funcid = "get_postcode_latitude"; var postcode = parseInt($('#i ...

How come when I go back through ajax, my markers always seem to land in the top left corner?

If you incorporate a Google Map on a webpage in http://jquerymobile.com, and navigate away from the page before returning, all the markers will relocate to the top left corner. For instance: This is how my jQuery JavaScript code begins: $('.page-m ...

Passing an array to PHP using AJAX

I have been attempting to send a JavaScript array to a PHP file using AJAX. Here is the JS code: $('#basket').on('click',function(){ $.ajax({ type: "GET", url: "basket.php", data: {vektor: itemNameArray}, ...

Cross Policy Issue: Response Status is not HTTP OK

I have developed a custom RESTful application using PHP that provides APIs for a JavaScript application. Everything is functioning smoothly, except when I include http_response_code in the response header. Below is the function I utilize to output the dat ...

Angular backend endpoints for serving non-HTML assets

My goal is to establish routing using ngRoute in Angular. I'm aware that when making GET requests to the backend, the expected response is to return index.html, which then loads Angular, allowing for the correct page to be constructed. The issue I&ap ...

An effective method for appending data to a multidimensional array in Google script

Is there a way to expand a multidimensional array of unknown size without relying on a Google Sheets spreadsheet to manage the data? I've searched everywhere but can't find an example for a 3-dimensional array. Here's the challenge I'm ...

I'm curious if there is a method to determine the status of a .net required field validator using JavaScript

I am attempting to determine the status of the "required field validators" within an .aspx file. By state, I am referring to whether they are enabled or disabled rather than if their contents are valid or invalid. I am aware that the enabled/disabled sta ...

Step-by-step guide on incorporating jQuery and Bootstrap into your project post npm installation

As I progressed in my coding journey, I decided to level up my skills by moving away from using CDNs and exploring new tools. One of the tools I delved into was NPM, mastering the basics like installation and updating. However, I found myself stuck when it ...

Does Typescript not provide typecasting for webviews?

Typescript in my project does not recognize webviews. An example is: const webview = <webview> document.getElementById("foo"); An error is thrown saying "cannot find name 'webview'". How can I fix this issue? It works fine with just javas ...

Thorax.js bower installation issue

After following the instructions in this guide: https://github.com/walmartlabs/thorax-seed/blob/master/README.md, I ran into an unexpected issue on my Windows machine. When running npm start It seems like bower is doing a lot of work (presumably loading ...

Tips for streamlining the use of hidden and visible div elements with concise code

I have been attempting to use the same code for multiple modules on this page, but none of the methods I've tried seem to be effective. I want to avoid endlessly duplicating existing code. document.addEventListener('DOMContentLoaded', fun ...

Is there a way to cancel an AJAX request during the ajaxStart or ajaxSend event in jQuery?

In my project, I have implemented numerous $.post methods and now I need to check the session in each request to handle my page based on session value. However, I don't want to modify all the existing methods ($.post). Instead, I would like to check t ...

Getting the id attribute value from MagicSuggest: A step-by-step guide

Utilizing a few MagicSuggest controls on my webpage, here is the code snippet: <div id="my_id1" class="magicsuggest"></div> <div id="my_id2" class="magicsuggest"></div> ... var ms = $('.magicsuggest').magicSuggest({}); ...

Follow us text placed in front of social sprite images all aligned on the same line

Is there a way to align the Follow Us text with sprite images? Check out this jsfiddle link for more details! <ul class="social_Emp">&nbsp;&nbsp;&nbsp;Follow us: <li class="Emp_twitter"><a href="{if $userInfo.TwitterPage} {$u ...

Tips for effectively eliminating errors in a redux store

Within my react-redux application, I have implemented a system to catch error responses from redux-saga. These errors are saved in the redux-store and rendered in the component. However, a major challenge arises when trying to remove these errors upon comp ...

Heroku is incompatible with deploying MERN applications

I've been working on deploying my React app through NodeJS and Heroku, but I keep encountering an issue in the browser. Uncaught SyntaxError: Unexpected token '<' Resulting in a blank white page being displayed. I've tried sever ...

Display targeted data from database using the Jade template engine

Here is the code from my app.js: for (var i=0; i<result.length; i++) { data['result'][i] = {company_name: result[i].company_name}; } res.render('findcompany', {data: data}); console.log(data); The result of console.log(data) sh ...

Renewing Masonry and JQuery

Currently implementing Masonry from into a project aimed at creating a timeline effect for user interaction. The goal is to automatically refresh the page at intervals (every 10 seconds during testing), but encountered an issue. Upon initial load, the ge ...

Is it common practice or a clever hack to use negative values for the top position in CSS?

I am working with a few Div's that have background images, and the top one has a curve design. I am trying to align the bottom Div with the curved top one, so I was considering using the following CSS properties: top: -39px; width: 260px; Would usi ...

Using Vue.js for handling events with the passing method

As a newcomer to Vue.js, I am currently trying to understand method event handling. My goal is to read a barcode using input from a web camera and display its raw content. The function works perfectly if I just render the raw content. However, when I att ...