CSS body element width not working

前端 未结 6 794
挽巷
挽巷 2021-01-28 14:32

HTML:


    

Some content

CSS:

body {
    margin: 0 auto;
    width: 470px;
    back         


        
6条回答
  •  再見小時候
    2021-01-28 15:28

    You're treating the body like a

    element. This is causing the text to be centered. Instead enclose your

    Some content

    inside a
    and maybe give it a class

    HTML:

    
       
    Some content

    CSS:

    .name{
        margin: 0 auto;
        width: 470px;
        background-color: cyan;
        text-align: center;
    }
    

    if you don't want to use a class or id or

    you can simple change all

    to that css

    CSS:
    
    p{
        margin: 0 auto;
        width: 470px;
        background-color: cyan;
        text-align: center;
    }
    

提交回复
热议问题