【新手请教】请问我的代码出了什么问题?为什么上部和左侧图案会重叠在一起?_html/css_WEB-ITnose
#header{
height:50px;
width:100%;
border:1px solid black;
border-radius:5px;
background:green;
padding:40px;
position:fixed;
z-index:1;
margin-bottom:10px;
}
#header p{display:inline;margin-left:20px;}
.left{
height:100px;
margin-top: 50px;
width:30%;
background-color:yellow;
border-radius:5px;
border:1px solid black;
float:left;
position:relative;
}
.right{
height:100px;
width:70%;
background-color:blue;
border-radius:5px;
border:1px solid black;
float:right;
}
#footer{
height:50px;
width:100%;
border:1px solid black;
border-radius:5px;
background:#ff0000;
padding:40px;
clear:both;
}
范例代码(节取)
#header {
z-index: 1;
position: fixed;
width: 97.5%;
margin-top: -20px;
height: 60px;
background-color: #668284;
margin-bottom: 10px;
}
h4 {
margin-left: 5px;
margin-bottom: 15px;
font-family: Verdana, sans-serif;
}
}
.left {
position: relative;
float: left;
margin-top: 50px;
width: 10%;
height: 400px;
background-color: #B9D7D9;
margin-bottom: 10px;
}
.right {
position: relative;
float: right;
margin-top: 50px;
width: 88%;
height: 400px;
background-color: #F4EBC3;
margin-bottom: 10px;
}
回复讨论(解决方案)
因为#header 中的 position: fixed;
因为#header 中的 position: fixed;
position改为相对之后,确实不再重叠了。可是这节课的内容就是使用position和float…而且为什么例题里面同样使用了“固定位置”,却没有出现同样的问题呢? 答: 30 % + 70% = 100%
但是你有边框并给了值,因此会超出100%,就变成这个样子了。
答: 30 % + 70% = 100%
但是你有边框并给了值,因此会超出100%,就变成这个样子了。
答: 30 % + 70% = 100%
但是你有边框并给了值,因此会超出100%,就变成这个样子了。
答: 30 % + 70% = 100%
但是你有边框并给了值,因此会超出100%,就变成这个样子了。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

本文讨论了html< datalist>元素,通过提供自动完整建议,改善用户体验并减少错误来增强表格。Character计数:159

本文讨论了HTML< Progress>元素,其目的,样式和与< meter>元素。主要重点是使用< progress>为了完成任务和LT;仪表>对于stati

本文讨论了HTML< meter>元素,用于在一个范围内显示标量或分数值及其在Web开发中的常见应用。它区分了< meter>从< progress>和前

本文讨论了< iframe>将外部内容嵌入网页,其常见用途,安全风险以及诸如对象标签和API等替代方案的目的。

本文讨论了视口元标签,这对于移动设备上的响应式Web设计至关重要。它解释了如何正确使用确保最佳的内容缩放和用户交互,而滥用可能会导致设计和可访问性问题。

本文讨论了使用HTML5表单验证属性,例如必需的,图案,最小,最大和长度限制,以直接在浏览器中验证用户输入。

本文解释了HTML5< time>语义日期/时间表示的元素。 它强调了DateTime属性对机器可读性(ISO 8601格式)的重要性,并在人类可读文本旁边,增强Accessibilit
