对于我的个人网站,我试图在加载时在屏幕底部显示带有我名字的横幅,无论其大小如何。
但我不希望横幅跟随屏幕。
这是我正在使用的横幅 CSS/HTML:
.header-card {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 20%;
margin: auto;
background: rgba(0, 0, 0, 0.5);
color: white;
}Run Code Online (Sandbox Code Playgroud)
<div class="header-card">
<h1>My Name</h1>
</div>Run Code Online (Sandbox Code Playgroud)
在浏览器窗口的底部:
.header-card {
position: fixed; //fixed is absolute to a browser
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
color: white;
}
<div class="header-card">
<h1>My Name</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
在页面底部(或父级“相对”元素):
.header-card {
position: absolute; // absolute is absolute to a relative element
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
color: white;
}
<div class="header-card">
<h1>My Name</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9639 次 |
| 最近记录: |