-1

I'm trying to create a website whose body up the middle 60%. I thought I'd do this:

body {
  align-items: center;
  text-align: left;
  justify-content: center;
  width: 60%;
}

But that's not working :(

I even tried using translateX to translate right 20%

Any advice? Suggestions?

Manny
  • 35
  • 6

3 Answers3

2

Try this html code :

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
</head>

<body>
  Hello World !
</body>

And then this CSS :

html {
    height: 100%;
}

body {
    width: 60%;
    margin: auto;
}

You can try this Website to code html, css, and javascript online.

I hope I've helped you.

Julien J
  • 2,826
  • 2
  • 25
  • 28
1

You can achieve it easily using CSS grid. Here's the MDN reference: https://developer.mozilla.org/en-US/docs/Web/CSS/grid

Example:

HTML file

<div class="container">
  <div class="content">
    Some content
  </div>
</div>

CSS file

.container {
  display: grid;
  grid-template-columns: 20% 60% 20%;
}

.content {
  grid-column: 2;
}
Paweł Jacewicz
  • 134
  • 1
  • 7
0

you can remove width and instead use

 right: 20%;
 left : 20%;

It'll work I guess And i think it would be better to use a div instead of body

Yvan Roan
  • 3
  • 2