我正在尝试制作一个带有固定标题和可滚动内容区域的网页.当标题具有已知高度时,这是微不足道的,但是当标题流畅时,我正在努力寻找解决方案.
我想要的布局是:
--------------
head
--------------
content
--------------
Run Code Online (Sandbox Code Playgroud)
其中"head"是其内容需要的高度,"content"没有最小高度,但在变为可滚动之前将达到视口底部的最大高度.
这些天在纯CSS中这可能吗?我的目标是IE8 +.
为了澄清我想要的东西,如果我知道标题的高度,我会怎么做:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
}
#head {
background: yellow;
height: 20px; /* I can't rely on knowing this. */
}
#content {
background: red;
position: absolute;
top: 20px; /* here also */
bottom: 0;
width: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div id="head">some variable height content</div>
<div id="content">
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/> …Run Code Online (Sandbox Code Playgroud) 是否可以String使用静态str值匹配Rust中的结构?这是一个最小的例子:
struct SomeStruct {
a: String,
}
fn main() {
let s = SomeStruct {
a: "Test".to_string(),
};
match s {
SomeStruct { a: "Test" } => {
println!("Match");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这将无法编译,因为静态str引用无法与String成员匹配.它可以在没有解构的情况下工作a,然后在匹配中添加嵌套的if语句吗?