search

Home  >  Q&A  >  body text

Margin:0 auto is set; why can't it be centered?

<!DOCTYPE html>

<html>

<head>

<meta charset ="UTF-8">

<title>1. Single-column equal-width layout</title>

<!--Style-->

<style type="text/css" >

.container{

max-width: 960px;<!--Set the maximum width to 960px-->

margin:0 auto;< !--Set the inner block element to be horizontally centered-->

}

.header{

height:50px;

background-color: #21ff80;

}

.main{

height:600px;

background-color:#80007f;

}

.footer{

height:100px;

background-color:#21ff80;

}

</style>


##</head>


##<body>

<h4>Single column, etc. Basic ideas of wide layout: </h4>

<p>1. The head, body and bottom of the page are all placed in a container and set uniformly<br>

2. The sub-blocks in the container only need to set the height

</p>

##<div>

< div>head</div>

<div>body</div>

<div>bottom</div>

</ div>


##</body>





#</html>


cp3cp32436 days ago1652

reply all(2)I'll reply

  • cp3

    cp32018-05-04 16:15:58

    Okay, it’s solved. There is a problem with the comments. I wrote it in Notepad++. I just used the shortcut keys to comment without paying attention.

    reply
    0
  • oswell

    oswell2018-05-04 16:09:30

    You only wrote the style, but did not use the style

    reply
    0
  • Cancelreply