When I run my web-page, it displays it with the header on the left and the footer on the right, even though I don’t want it to. I want it to display downwards.
My HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Alan Turing</title>
<link rel="stylesheet" type="text/css" href="MyStyles.css">
</head>
<body>
<header>
<h5>Alan Turing</h5>
</header>
<nav>
<a href="Home.html">Home</a>
<a href="Biography.html"> Biography</a>
<a href="Quiz.html"> Quiz</a>
<a href="About.html"> About</a>
</nav>
<article>
<h2>Alan Turing</h2>
<p>Welcome to my Alan Turing website. Click on Biography to read about him, quiz to havea test about him. Click about to see about this web page and other useful websites.</p>
<img alt="Alan turing" src="Assets/alanTuring.jpg">
<p>Above is a picture of Alan Turing, who is famous for cracking the enigma code in World War 2.</p>
<h3>An overview on who he was</h3>
<p>Alan Turing was an English mathematician and pioneer of theoretical computer science and artificial intelligence. During WW2, he was instrumental in breaking the German Enigma code, leading to Allied victory over Nazi Germany.</p>
</article>
</body>
And my CSS code:
header {
padding: 35px;
text-align: center;
background:darkgreen;
color: darkgray;
font-size: 40px;
}
nav {
padding: 20px;
background: green;
color: darkgrey;
font-size: 20px
}
article {
padding: 100px;
text-align: center;
background: lightgreen;
}
@import url('https://fonts.googleapis.com/css?
family=Source+Code+Pro&display=swap');
body {
font-family: 'Source Code Pro', monospace;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
I have tried deleting some things, like each section, however it hasn’t worked.
Thanks in advance!
2
Answers
Remove the
display: flex
and related properties frombody
You have set
body
todisplay: flex
. The default direction of a flexbox isrow
. That’s why your page is displaying left to right. To change this, so your flex parent displays its children in a column, add this line tobody
:Here’s a little demo to help illustrate changing
flex-direction
fromrow
(the default) tocolumn
.