У меня есть страница, на которой есть раздел, навигация, статья. Раздел содержит навигацию и статью. На данный момент навигация и статья занимают всю страницу. Но мне нужна статья, а навигация должна быть в центре страницы. Я упомянул https://www.w3schools.com/html/html_layout.asp и разработал веб-страницу. Мой html код выглядит следующим образом
<header class="header header-default header">
<div class="container-fluid">
<div class="header-header">
<a class="header-brand" href="#">
<img></img></a>
</a>
<h1>My application</h1>
</div>
</div>
</header>
<section>
<nav>
<label for='Date'>Choose the booking date:</label>
<input type='text' name='datefield' id='datepicker' readonly='true' placeholder="Select the booking date...">
<input class="btn btn-success" type='button' id='submit' value='Submit'>
</nav>
<article>
<div>
<p></p>
</div>
</article>
</section>
Мой css выглядит следующим образом
/* Create two columns/boxes that floats next to each other */
nav {
float: left;
width: 30%;
height: 300px; /* only for demonstration, should be removed */
background: #ccc;
padding: 20px;
}
article {
float: left;
padding: 20px;
width: 70%;
background-color: #f1f1f1;
height: 300px; /* only for demonstration, should be removed */
}
/* Clear floats after the columns */
section:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */
@media (max-width: 600px) {
nav, article {
width: 100%;
height: auto;
}
}
При ссылке на CSS Получение Центра статей есть включено поле слева: авто; поле справа: авто; в «разделе»
section:after {
content: "";
display: table;
clear: both;
margin-left: auto;
margin-right: auto;
Это не дало мне ожидаемый результат, что я хочу. Ожидаемый результат: навигация и статья должны быть в середине страницы.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="C:Users/annap/code/interview-scheduler/qxf2_scheduler/static/css/qxf2_scheduler.css" rel="stylesheet">
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Abel|Open+Sans:400,600" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<style>
/* Create two columns/boxes that floats next to each other */
nav {
float: left;
width: 30%;
height: 300px; /* only for demonstration, should be removed */
background: #ccc;
padding: 20px;
}
article {
float: left;
padding: 20px;
width: 70%;
background-color: #f1f1f1;
height: 300px; /* only for demonstration, should be removed */
}
/* Clear floats after the columns */
section:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */
@media (max-width: 600px) {
nav, article {
width: 100%;
height: auto;
}
}
</style>
</head>
<body>
<header class="header header-default header">
<div class="container-fluid">
<div class="header-header">
<a class="header-brand" href="#">
<img></img></a>
</a>
<h1>My application</h1>
</div>
</div>
</header>
<section>
<nav>
<label for='Date'>Choose the booking date:</label>
<input type='text' name='datefield' id='datepicker' readonly='true' placeholder="Select the booking date...">
<input class="btn btn-success" type='button' id='submit' value='Submit'>
</nav>
<article>
<div>
<p></p>
</div>
</article>
</section>
</body>
</html>
What I need is the choose the booking date(nav) and the article should be in middle leaving the space in the left and right. As of now, you can see it's the full width of the page