После очистки: оба, float div не идут наверх - PullRequest
0 голосов
/ 24 января 2019

Я делаю адаптивный веб-сайт и использую «float» и «clear: both», чтобы поместить все элементы div в соответствующие места.Но после использования «clear: both» «div 6» не переходит на верхнюю часть справа.Чтобы уточнить (изображение):

нажмите для просмотра изображения

HTML:

<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Title</title>
</head>
<body>

<div class="container">
<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
<div class="div4">4</div>
<div class="clear"></div>
<div class="div5">5</div>
<div class="div6">6</div>
</div>

</body>
</html>

CSS:

.clear
{
clear:both;
}

.container
{
width: 100%;
height:auto;
position:relative;
left: 0;
top: 0;
display:table;
background-color:#CCC;
}

.div1
{
background-color:#FF0;
position:relative;
width: 50%;
height:200px;
float:left;
margin-left:0;
}
@media screen and (max-width: 700px)
{
.div1
{
background-color:#FF0;
position:relative;
width: 100%;
height:200px;
float:left;
margin-left:0;
}
}

.div2
{
background-color:#FC0;
position:relative;
width: 50%;
height:40px;
float:right;
margin-right:0;
}
@media screen and (max-width: 700px)
{
.div2
{
background-color:#FC0;
position:relative;
width: 100%;
height:40px;
float:left;
margin-left:0;
}
}

.div3
{
background-color:#F90;
position:relative;
width: 50%;
height:40px;
float:right;
margin-right:0;
}
@media screen and (max-width: 700px)
{
.div3
{
background-color:#F90;
position:relative;
width: 100%;
height:40px;
float:left;
margin-left:0;
}
}

.div4
{
background-color:#F60;
position:relative;
width: 50%;
height:40px;
float:right;
margin-right:0;
}
@media screen and (max-width: 700px)
{
.div4
{
background-color:#F60;
position:relative;
width: 100%;
height:40px;
float:left;
margin-left:0;
}
}

.div5
{
background-color:#0C6;
position:relative;
width: 50%;
height:80px;
float:left;
margin-left:0;
}
@media screen and (max-width: 700px)
{
.div5
{
background-color:#0C6;
position:relative;
width: 100%;
height:80px;
float:left;
margin-left:0;
}
}

.div6
{
background-color:#396;
position:relative;
width: 50%;
height:40px;
float:right;
margin-right:0;
}
@media screen and (max-width: 700px)
{
.div6
{
background-color:#396;
position:relative;
width: 100%;
height:40px;
float:left;
margin-left:0;
}
}

Я полагаю, что это простое решение, но я пытаюсь решить эту проблему.

Пожалуйста, помогите мне!

...