Foundation Top-Bar 在某些尺寸下不起作用
Foundation Top-Bar not working at certain sizes
我正在使用 Zurbs 响应式框架基础。
我决定让顶部栏在大屏幕上变成汉堡包图标,因为我有很多菜单选项,当在中等尺寸的屏幕(例如药片。
所以我找到了正在确定大小的媒体查询
@media only screen and (min-width: 40rem) {...}
我将其更改为 1025 像素,现在它显示在 1025 像素和更小的屏幕上。问题是当在较小的屏幕上打开并变大时,实际菜单将不会打开或保持打开状态。
我认为这与某处设置的最大宽度有关,但我在该媒体查询中发现的最大宽度没有任何改变。
这是整个查询
@media only screen and (min-width: 1024px) {
.top-bar {
background: #333333;
overflow: visible; }
.top-bar:before, .top-bar:after {
content: " ";
display: table; }
.top-bar:after {
clear: both; }
.top-bar .toggle-topbar {
display: none; }
.top-bar .title-area {
float: left; }
.top-bar .name h1 a {
width: auto; }
.top-bar input,
.top-bar .button,
.top-bar button {
font-size: 0.875rem;
position: relative;
height: 1.75rem;
top: 0.53125rem; }
.top-bar.expanded {
background: #333333; }
.contain-to-grid .top-bar {
/*max-width: 62.5rem;*/
margin: 0 auto;
margin-bottom: 0; }
.top-bar-section {
transition: none 0 0;
left: 0 !important; }
.top-bar-section ul {
width: auto;
height: auto !important;
display: inline; }
.top-bar-section ul li {
float: left; }
.top-bar-section ul li .js-generated {
display: none; }
.top-bar-section li.hover > a:not(.button) {
background-color: #555555;
background: #333333;
color: #FFFFFF; }
.top-bar-section li:not(.has-form) a:not(.button) {
padding: 0 0.9375rem;
line-height: 2.8125rem;
background: #f68c3b; }
.top-bar-section li:not(.has-form) a:not(.button):hover {
background-color: #555555;
background: pink; }
.top-bar-section li.active:not(.has-form) a:not(.button) {
padding: 0 0.9375rem;
line-height: 2.8125rem;
color: #FFFFFF;
background: #008CBA; }
.top-bar-section li.active:not(.has-form) a:not(.button):hover {
background: #0078a0;
color: #FFFFFF; }
.top-bar-section .has-dropdown > a {
padding-right: 2.1875rem !important; }
.top-bar-section .has-dropdown > a:after {
content: "";
display: block;
width: 0;
height: 0;
border: inset 5px;
border-color: rgba(255, 255, 255, 0.4) transparent transparent transparent;
border-top-style: solid;
margin-top: -2.5px;
top: 1.40625rem; }
.top-bar-section .has-dropdown.moved {
position: relative; }
.top-bar-section .has-dropdown.moved > .dropdown {
display: block;
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px); }
.top-bar-section .has-dropdown.hover > .dropdown, .top-bar-section .has-dropdown.not-click:hover > .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.top-bar-section .has-dropdown > a:focus + .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.top-bar-section .has-dropdown .dropdown li.has-dropdown > a:after {
border: none;
content: "[=11=]bb";
top: 1rem;
margin-top: -1px;
right: 5px;
line-height: 1.2; }
.top-bar-section .dropdown {
left: 0;
top: auto;
background: transparent;
min-width: 100%; }
.top-bar-section .dropdown li a {
color: #FFFFFF;
line-height: 2.8125rem;
white-space: nowrap;
padding: 12px 0.9375rem;
background: #333333; }
.top-bar-section .dropdown li:not(.has-form):not(.active) > a:not(.button) {
color: #FFFFFF;
background: #333333; }
.top-bar-section .dropdown li:not(.has-form):not(.active):hover > a:not(.button) {
color: #FFFFFF;
background-color: #555555;
background: #333333; }
.top-bar-section .dropdown li label {
white-space: nowrap;
background: #333333; }
.top-bar-section .dropdown li .dropdown {
left: 100%;
top: 0; }
.top-bar-section > ul > .divider, .top-bar-section > ul > [role="separator"] {
border-bottom: none;
border-top: none;
border-right: solid 1px #4e4e4e;
clear: none;
height: 2.8125rem;
width: 0; }
.top-bar-section .has-form {
background: #333333;
padding: 0 0.9375rem;
height: 2.8125rem; }
.top-bar-section .right li .dropdown {
left: auto;
right: 0; }
.top-bar-section .right li .dropdown li .dropdown {
right: 100%; }
.top-bar-section .left li .dropdown {
right: auto;
left: 0; }
.top-bar-section .left li .dropdown li .dropdown {
left: 100%; }
.no-js .top-bar-section ul li:hover > a {
background-color: #555555;
background: #333333;
color: #FFFFFF; }
.no-js .top-bar-section ul li:active > a {
background: #008CBA;
color: #FFFFFF; }
.no-js .top-bar-section .has-dropdown:hover > .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.no-js .top-bar-section .has-dropdown > a:focus + .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; } }
您不必 "hack" Tob Bar css 即可在某些断点处显示移动布局。您所要做的就是编辑现有的 Foundation 设置 css 文件。
因此,例如,Top Bar 有一组可用的 SCSS 变量,您可以在此处查看它们 - http://foundation.zurb.com/docs/components/topbar.html
您要找的是:
$topbar-breakpoint: #{lower-bound($medium-range)}; // Change to 9999px for always mobile layout
如果您只使用 CSS 下载,您可以在 2 个地方更改 CSS 来更改顶部栏断点。这是 link 对发布
的回答
http://foundation.zurb.com/forum/posts/1053-changing-topbar-breakpoint-using-css
我正在使用 Zurbs 响应式框架基础。
我决定让顶部栏在大屏幕上变成汉堡包图标,因为我有很多菜单选项,当在中等尺寸的屏幕(例如药片。
所以我找到了正在确定大小的媒体查询
@media only screen and (min-width: 40rem) {...}
我将其更改为 1025 像素,现在它显示在 1025 像素和更小的屏幕上。问题是当在较小的屏幕上打开并变大时,实际菜单将不会打开或保持打开状态。
我认为这与某处设置的最大宽度有关,但我在该媒体查询中发现的最大宽度没有任何改变。
这是整个查询
@media only screen and (min-width: 1024px) {
.top-bar {
background: #333333;
overflow: visible; }
.top-bar:before, .top-bar:after {
content: " ";
display: table; }
.top-bar:after {
clear: both; }
.top-bar .toggle-topbar {
display: none; }
.top-bar .title-area {
float: left; }
.top-bar .name h1 a {
width: auto; }
.top-bar input,
.top-bar .button,
.top-bar button {
font-size: 0.875rem;
position: relative;
height: 1.75rem;
top: 0.53125rem; }
.top-bar.expanded {
background: #333333; }
.contain-to-grid .top-bar {
/*max-width: 62.5rem;*/
margin: 0 auto;
margin-bottom: 0; }
.top-bar-section {
transition: none 0 0;
left: 0 !important; }
.top-bar-section ul {
width: auto;
height: auto !important;
display: inline; }
.top-bar-section ul li {
float: left; }
.top-bar-section ul li .js-generated {
display: none; }
.top-bar-section li.hover > a:not(.button) {
background-color: #555555;
background: #333333;
color: #FFFFFF; }
.top-bar-section li:not(.has-form) a:not(.button) {
padding: 0 0.9375rem;
line-height: 2.8125rem;
background: #f68c3b; }
.top-bar-section li:not(.has-form) a:not(.button):hover {
background-color: #555555;
background: pink; }
.top-bar-section li.active:not(.has-form) a:not(.button) {
padding: 0 0.9375rem;
line-height: 2.8125rem;
color: #FFFFFF;
background: #008CBA; }
.top-bar-section li.active:not(.has-form) a:not(.button):hover {
background: #0078a0;
color: #FFFFFF; }
.top-bar-section .has-dropdown > a {
padding-right: 2.1875rem !important; }
.top-bar-section .has-dropdown > a:after {
content: "";
display: block;
width: 0;
height: 0;
border: inset 5px;
border-color: rgba(255, 255, 255, 0.4) transparent transparent transparent;
border-top-style: solid;
margin-top: -2.5px;
top: 1.40625rem; }
.top-bar-section .has-dropdown.moved {
position: relative; }
.top-bar-section .has-dropdown.moved > .dropdown {
display: block;
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px); }
.top-bar-section .has-dropdown.hover > .dropdown, .top-bar-section .has-dropdown.not-click:hover > .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.top-bar-section .has-dropdown > a:focus + .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.top-bar-section .has-dropdown .dropdown li.has-dropdown > a:after {
border: none;
content: "[=11=]bb";
top: 1rem;
margin-top: -1px;
right: 5px;
line-height: 1.2; }
.top-bar-section .dropdown {
left: 0;
top: auto;
background: transparent;
min-width: 100%; }
.top-bar-section .dropdown li a {
color: #FFFFFF;
line-height: 2.8125rem;
white-space: nowrap;
padding: 12px 0.9375rem;
background: #333333; }
.top-bar-section .dropdown li:not(.has-form):not(.active) > a:not(.button) {
color: #FFFFFF;
background: #333333; }
.top-bar-section .dropdown li:not(.has-form):not(.active):hover > a:not(.button) {
color: #FFFFFF;
background-color: #555555;
background: #333333; }
.top-bar-section .dropdown li label {
white-space: nowrap;
background: #333333; }
.top-bar-section .dropdown li .dropdown {
left: 100%;
top: 0; }
.top-bar-section > ul > .divider, .top-bar-section > ul > [role="separator"] {
border-bottom: none;
border-top: none;
border-right: solid 1px #4e4e4e;
clear: none;
height: 2.8125rem;
width: 0; }
.top-bar-section .has-form {
background: #333333;
padding: 0 0.9375rem;
height: 2.8125rem; }
.top-bar-section .right li .dropdown {
left: auto;
right: 0; }
.top-bar-section .right li .dropdown li .dropdown {
right: 100%; }
.top-bar-section .left li .dropdown {
right: auto;
left: 0; }
.top-bar-section .left li .dropdown li .dropdown {
left: 100%; }
.no-js .top-bar-section ul li:hover > a {
background-color: #555555;
background: #333333;
color: #FFFFFF; }
.no-js .top-bar-section ul li:active > a {
background: #008CBA;
color: #FFFFFF; }
.no-js .top-bar-section .has-dropdown:hover > .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; }
.no-js .top-bar-section .has-dropdown > a:focus + .dropdown {
display: block;
position: static !important;
height: auto;
width: auto;
overflow: visible;
clip: auto;
position: absolute !important; } }
您不必 "hack" Tob Bar css 即可在某些断点处显示移动布局。您所要做的就是编辑现有的 Foundation 设置 css 文件。
因此,例如,Top Bar 有一组可用的 SCSS 变量,您可以在此处查看它们 - http://foundation.zurb.com/docs/components/topbar.html
您要找的是:
$topbar-breakpoint: #{lower-bound($medium-range)}; // Change to 9999px for always mobile layout
如果您只使用 CSS 下载,您可以在 2 个地方更改 CSS 来更改顶部栏断点。这是 link 对发布
的回答http://foundation.zurb.com/forum/posts/1053-changing-topbar-breakpoint-using-css