四时宝库

程序员的知识宝库

CSS 全屏布局(css全屏背景图)

什么是全屏布局

全屏布局就是指 HTML 页面铺满整个浏览器窗口, 并且没有滚动条。而且还可以跟随浏览器的大小变化而变化。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>全屏布局</title>
<style>
html,
    body {
    margin: 0;
    overflow: hidden;
}
header {
    height: 100px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: lightgray;
}
.content {
    position: fixed;
    left: 0;
    right: 0;
    top: 100px;
    bottom: 100px;
    overflow: auto;
    background-color: lightblue;
}
.content .left {
    width: 300px;
    height: 100%;
    position: fixed;
    left: 0;
    top: 100px;
    bottom: 100px;
    background-color: lightcoral;
}
.content .right {
    height: 1000px;
    margin-left: 300px;
    background-color: greenyellow;
}
footer {
    height: 100px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: lightslategray;
}
</style>
</head>
<body>
<header></header>
<div class="content">
<div class="left"></div>
<div class="right"></div>
</div>
<footer></footer>
</body>
</html>

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接