html - 是否可以将块下方堵塞?
问题描述
header {
background: blue;
color: white;
width: 100%;
}
.container {
background: green;
text-align: center;
width: 100%;
height: 100px;
transform: skew(0, -10deg);
color: white;
position: relative;
top: 55px;
}
.container .home{
position:absolute;
bottom:0;
}
<header class="header">
<div class="logo">
<i class="fab fa-accusoft"></i>
<span class="title">DreamCoding</span>
</div>
<section class="container">
<div class="home">
<div class="title">Alphabet</div>
<div class="text">
abcdefg
</div>
</div>
</section>
我有盒子和盒子。我试图用标题框盖住容器框。问题是该框一次又一次地被 , 框覆盖。
我不确定我是否解释得当,因为英语不是我的母语。无论如何,提前谢谢。
解决方案
只需将z-index
属性添加到两个元素。可运行代码片段如下:
header {
background: blue;
color: white;
width: 100%;
z-index: 1;
}
.container {
background: green;
text-align: center;
width: 100%;
height: 100px;
transform: skew(0, -10deg);
color: white;
position: relative;
top: 55px;
z-index: -1;
}
.container .home {
position: absolute;
bottom: 0;
}
<html>
<body>
<header class="header">
<div class="logo">
<i class="fab fa-accusoft"></i>
<span class="title">DreamCoding</span>
</div>
<section class="container">
<div class="home">
<div class="title">Alphabet</div>
<div class="text">
abcdefg
</div>
</div>
</section>
</header>
</body>
</html>
**z-index 属性用于使元素与其他元素重叠。
推荐阅读
- java - 为什么这个三元运算返回空指针异常?
- python - 有什么方法可以将 f 字符串合并到标识符中?
- javascript - 关闭后不显示引导模式
- python - wide to long with multiple header rows and merged cells
- python - 如何使用自定义度量(设置距离)构造成对距离矩阵?
- weka - 将 Weka Fiji 插件分段导出为 ROI
- php - PHP多维数组搜索键
- c++ - 从 keras 保存 .pb 和 .pbtxt 文件
- http - 相同 IP 地址的内部 LB 错误
- html - 使用 css 的幻灯片中的导航项目符号也无法为背景图像保持相同的大小