很久都没有更新了,今天再更新一些使用的小技巧,今天给大家带来的内容是如何快速的将一行 div 元素设置到屏幕底部,今天的主要内容有
先给大家看一看效果图

这个样式我们需要做如下处理 HTML 部分
CSS样式设置部分 4. 通过外部文件,通过 link 标签引用 css 样式文件。 5. 设置 width = 100%, height = 50px; 6. z-index: 设置 100 7. flex 布局,居中处理
但是这样会显得代码冗余,因此不建议这么做
<html lang="en">
<head>
<meta charset="UTF-8">
<title>将一行元素置于底部title>
<style>
div {
left: 0;
position: fixed;
bottom: 0;
/* top 0 就是顶部 */
width: 100%;
z-index: 100;
background: #343537;
display: flex;
justify-content: center;
color: #ffff;
}
style>
head>
<body>
<div class="bottom-item">
<p>Copyright @ 2019 XXXX p>
div>
body>
html>推荐这种方式,这样可以使样式和内容分离的效果,优化效果 index.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>将一行元素置于底部title>
<link type="text/css" rel="stylesheet" href="index.css">
head>
<body>
<div class="bottom-item">
<p>Copyright @ 2019 XXXX p>
div>
body>
html>这里通过link 引用外部样式,这是一个标准的写法
index.css
.bottom-item {
left: 0;
position: fixed;
bottom: 0;
/* top 0 就是顶部 */
width: 100%;
z-index: 100;
background: #343537;
display: flex;
justify-content: center;
color: #ffff;
}今天的内容就到这里了,你学会了嘛!!!