Foundation 6.4.3 Off-Canvas容器失效问题求助
Hey there! The main reason your Off-Canvas menu isn't showing up is that you're missing the trigger button needed to toggle it open. Foundation's Off-Canvas component is hidden by default—you need a button (or any interactive element) with the right data attribute to make it appear.
Let's walk through the fix step by step:
Step 1: Add the Toggle Button
Inside your off-canvas-content container, add a button with the data-toggle attribute set to match your Off-Canvas container's ID (offCanvas). Here's how to update that section of your code:
<div class="off-canvas-content" data-off-canvas-content> <!-- Trigger button for Off-Canvas menu --> <button type="button" class="button" data-toggle="offCanvas">Open Menu</button> <!-- Your page content lives here --> Welcome ! </div>
Step 2: Confirm Your Existing Setup is Correct
Good news—most of your code is already right:
- You've used the proper Off-Canvas wrapper structure (
off-canvas-wrapper→off-canvas+off-canvas-content) - All required data attributes are in place (
data-off-canvas,data-off-canvas-content,data-closeon the menu's close button) - Foundation JS initialization (
$(document).foundation();) is correctly placed after loading the Foundation script file.
Optional: Set Default Open State (If Needed)
If you want the menu to be visible as soon as the page loads, add the is-open class to your Off-Canvas container:
<div class="off-canvas position-left is-open" id="offCanvas" data-off-canvas>
Once you add the trigger button, clicking it should slide out your menu exactly as expected.
内容的提问来源于stack exchange,提问作者belgoros

