Zurb Foundation 6 增加 offcanvas 的大小使其在加载时可见
Zurb Foundation 6 Increasing the size of offcanvas makes it visible while loading time
用 Zurb Foundation 建立一个网站,我正在使用 off-canvas 功能。
关闭-canvas 区域的默认宽度是 250px,我想将其增加到,比方说,600px。
不幸的是,当我增加 off-canvas 的宽度时,它在加载时变得可见...
此外,我注意到当您展开或关闭 off-canvas 时,如果它大于 250px,则 "slide" 仅适用于 250px。
这是要测试的 HTML 代码:
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Foundation for Sites</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/css/foundation.min.css">
<style>
#off-canvas-right {
width: 600px;
}
</style>
</head>
<body>
<div class="off-canvas position-left" id="off-canvas-left" data-off-canvas>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad cumque, eligendi. Deleniti rerum, distinctio tempora laboriosam velit incidunt hic asperiores officiis alias ea, sequi libero animi soluta totam, quia veritatis.
</div>
<div class="off-canvas position-right" id="off-canvas-right" data-off-canvas>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore voluptate velit, labore, voluptatem quia laborum temporibus asperiores at eos nulla nam ab fugit tenetur quaerat iusto architecto eum ea explicabo.
</div>
<div class="off-canvas-content" data-off-canvas-content>
<a data-open="off-canvas-left" class="text-center">Open left</a>
<a data-open="off-canvas-right" class="text-center">Open right</a>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
有什么想法可以帮助解决这两个问题吗?
您只需添加 CSS 即可在所有状态下进行转换。我认为这也是导致页面加载视图跳转的原因。我相信将此添加到您的样式中会起作用:
#off-canvas-right {
&.off-canvas {
width: 600px;
transform: translateX(600px);
&.is-open {
transform: translate(0, 0);
}
}
}
用 Zurb Foundation 建立一个网站,我正在使用 off-canvas 功能。
关闭-canvas 区域的默认宽度是 250px,我想将其增加到,比方说,600px。
不幸的是,当我增加 off-canvas 的宽度时,它在加载时变得可见...
此外,我注意到当您展开或关闭 off-canvas 时,如果它大于 250px,则 "slide" 仅适用于 250px。
这是要测试的 HTML 代码:
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Foundation for Sites</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/css/foundation.min.css">
<style>
#off-canvas-right {
width: 600px;
}
</style>
</head>
<body>
<div class="off-canvas position-left" id="off-canvas-left" data-off-canvas>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad cumque, eligendi. Deleniti rerum, distinctio tempora laboriosam velit incidunt hic asperiores officiis alias ea, sequi libero animi soluta totam, quia veritatis.
</div>
<div class="off-canvas position-right" id="off-canvas-right" data-off-canvas>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore voluptate velit, labore, voluptatem quia laborum temporibus asperiores at eos nulla nam ab fugit tenetur quaerat iusto architecto eum ea explicabo.
</div>
<div class="off-canvas-content" data-off-canvas-content>
<a data-open="off-canvas-left" class="text-center">Open left</a>
<a data-open="off-canvas-right" class="text-center">Open right</a>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
有什么想法可以帮助解决这两个问题吗?
您只需添加 CSS 即可在所有状态下进行转换。我认为这也是导致页面加载视图跳转的原因。我相信将此添加到您的样式中会起作用:
#off-canvas-right {
&.off-canvas {
width: 600px;
transform: translateX(600px);
&.is-open {
transform: translate(0, 0);
}
}
}