JQuery-ui 填充模式下的手风琴和溢出 - 无关的 2px
JQuery-ui accordion in fill mode and overflow - extraneous 2px
在 this fiddle PoC 中,如果需要,我需要将 JQuery-ui 手风琴的高度降低两个 额外的无法解释的 像素摆脱溢出的垂直滚动条。
- 我处于
'fill'
heightStyle
模式,如下所示。
- 我手风琴的高度是正文的高度减去页脚和页眉的高度。 负 2 个像素。
- 所有库都是最新版本(在撰写本文时),除了 jquery 不在“3”中。
- 我知道
accordion.refresh()
和 css flex
但我对 "why" 很好奇,我宁愿在填充之前使用 calc()我的 CSS 带有弹性盒子。
$( function() {
$( "#accordion" ).accordion({heightStyle: 'fill' });
} );
html, body {
height: 100%;
}
:root{
--header-height: 40px;
--footer-height: 40px;
--two-unexplained-px: 2px;
}
body {
overflow:auto;
background-color: red;
}
* {
margin: 0px;
padding: 0px;
}
#header, #footer {
background-color: #adf;
}
#header {
height: var(--header-height);
}
#footer {
height: var(--footer-height);
}
#accordion {
height: calc(100% - var(--header-height) - var(--footer-height) - var(--two-unexplained-px));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
<div id="header">Header here</div>
<div id="accordion"><h2><a>Work here</a></h2><div>Text Here</div></div>
<div id="footer">Footer here</div>
另外两个像素来自这个规则:
.ui-accordion .ui-accordion-header {
margin: 2px 0 0 0;
}
在 this fiddle PoC 中,如果需要,我需要将 JQuery-ui 手风琴的高度降低两个 额外的无法解释的 像素摆脱溢出的垂直滚动条。
- 我处于
'fill'
heightStyle
模式,如下所示。 - 我手风琴的高度是正文的高度减去页脚和页眉的高度。 负 2 个像素。
- 所有库都是最新版本(在撰写本文时),除了 jquery 不在“3”中。
- 我知道
accordion.refresh()
和 cssflex
但我对 "why" 很好奇,我宁愿在填充之前使用 calc()我的 CSS 带有弹性盒子。
$( function() {
$( "#accordion" ).accordion({heightStyle: 'fill' });
} );
html, body {
height: 100%;
}
:root{
--header-height: 40px;
--footer-height: 40px;
--two-unexplained-px: 2px;
}
body {
overflow:auto;
background-color: red;
}
* {
margin: 0px;
padding: 0px;
}
#header, #footer {
background-color: #adf;
}
#header {
height: var(--header-height);
}
#footer {
height: var(--footer-height);
}
#accordion {
height: calc(100% - var(--header-height) - var(--footer-height) - var(--two-unexplained-px));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
<div id="header">Header here</div>
<div id="accordion"><h2><a>Work here</a></h2><div>Text Here</div></div>
<div id="footer">Footer here</div>
另外两个像素来自这个规则:
.ui-accordion .ui-accordion-header {
margin: 2px 0 0 0;
}