我想一个接一个地添加两个div。虽然位置相对工作正常。但为什么没有位置就会发生如果没有职位,是否有可能做到这一点。
这是html部分:
<div class="content1">
Lorem Ipsum is simply dummy text
<div>
<div class="content2">
Lorem Ipsum is simply dummy text
<div>
CSS部分:
.content1{
width: 100%;
height: 400px;
border: 1px solid black;
}
.content2{
width: 100%;
height: 300px;
border: 1px solid red;
}
.content1{
width: 100%;
height: 400px;
border: 1px solid black;
}
.content2{
width: 100%;
height: 300px;
border: 1px solid red;
}
<div class="content1">
Lorem Ipsum is simply dummy text
<div>
<div class="content2">
Lorem Ipsum is simply dummy text
<div>
答案 0 :(得分:4)
您没有正确关闭<div>
。
要关闭<div>
阻止,请使用</div>
。像这样:
<div class="content1">
Lorem Ipsum is simply dummy text
</div> <!-- Changed -->
<div class="content2">
Lorem Ipsum is simply dummy text
</div> <!-- Changed -->
答案 1 :(得分:2)
只需关闭<div>
代码
.content1 {
width: 100%;
height: 400px;
border: 1px solid black;
}
.content2 {
width: 100%;
height: 300px;
border: 1px solid red;
}
<div class="content1">
Lorem Ipsum is simply dummy text
</div>
<div class="content2">
Lorem Ipsum is simply dummy text
</div>
答案 2 :(得分:1)
关闭div
代码
<div class="content1">Lorem Ipsum is simply dummy text</div>
<div class="content2">Lorem Ipsum is simply dummy text</div>