Vielleicht wurde dies bereits beantwortet, konnte aber weder in Google, noch in Stackoverflow die Lösung finden. Neuling hier.CSS - wie man Website für große Bildschirme zentriert (ohne Bootstrap)
Ich benutze einen großen Bildschirm zu Hause und verwende selten den Browser im Vollbildmodus. Aber heute habe ich versucht zu sehen, wie eine Website, die ich teste, aussehen würde, und es ist hässlich. Im normalen Browser ist es in Ordnung, aber auf einem großen Bildschirm ist alles auf der linken Seite. Wie kann ich es für große Bildschirme zentrieren?
Ich weiß, ich könnte es füllen und Dinge für große Bildschirme größer machen, aber ich möchte lernen, wie dies zu tun, falls ich es brauche.
Hier ist meine HTML und CSS-Dateien
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<header class="col-12">
<!--logo-->
<div class="col-3 logo">
<img alt="logo" src="logo-lxfcl-new.png" width="210" height="54">
</div>
<div class="col-9 topMenu">
<h4>Welcome</h4>
<!--top menu-->
<nav>
<ul>
<li>Home</li>
<li>Annonces</li>
<li>Comment faire</li>
<li>contacts</li>
</ul>
</nav>
</div>
</header>
<!--left menu-->
<nav class="col-3 sidemenu">
<ul>
<li>Ateliers</li>
<li>Associations</li>
</ul>
</nav>
<main class="col-9 sectionColor">
<section>
sdfsdefwef
</section>
</main>
<!--footer-->
<footer class="col-12">
copyright
</footer>
/*defining the grid system*/
* {
box-sizing: border-box;
}
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%; max-width: 300px;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%; max-width: 900px;}
.col-9 {width: 75%; max-width: 900px;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%; max-width: 1200px;}
[class*="col-"] {
float: left;
padding: 10px;
border: solid 1px;
}
.row::after {
content: "";
clear: both;
display: table;
}
/*-------------------------------------*/
header, aside, footer, main, nav, section {
display: block;
}
/*---------------------------------------------*/
body {
font-family: roboto;
font-size: 1em;
line-height: 150%;
background-color: #dddddd;
margin: 0 auto;
}
.logo {
float:left;
}
.logo img {
display: block;
margin-left: auto;
margin-right: auto;
}
.topMenu {
float:left;
clear: right;
padding: 0px;
text-align: center;
}
.topMenu nav,
.topMenu h4 {
padding: 0;
}
.topMenu li {
display: inline;
list-style-type: none;
color: #5e2f2f;
padding-right: 30px;
}
.sidemenu li {
border-bottom: dotted 1px #5e2f2f;
list-style-type: none;
line-height: 200%;
color: #72a1e7;
margin-left: -40px; /*this is because of the default webkit-padding*/
max-width: 300px;
}
nav {
clear: left;
padding-top: 10px;
font-size: 0.9em;
}
.sectionColor {
background-color: white;
}
footer {
clear: both;
text-align: right;
padding-right: 20px;
font-style: italic;
font-size: 0.8em;
}
Also, Sie wollen nicht Bootstrap, aber Sie versuchen, Bootstrap zu replizieren? . . . Was?! –
ich lerne, und ich möchte nicht eine externe Bibliothek oder ein Framework aufrufen. Ich möchte alles tun, damit ich lernen und verstehen kann, was ich tue. Später werde ich es benutzen. – fields
Das macht Sinn. Erneutes Implementieren von Teilen des Frameworks, um zu verstehen, warum sie das tun. Sie sollten auch die Dokumentation und die Kommentare zum Code lesen. Die werden auch helfen. –