How to make text vertically and horizontally center in an HTML page

前端 未结 7 1694
眼角桃花
眼角桃花 2020-12-01 20:58

I have some experience with Java , C , databases , networking etc..But anything related with Html I am a begginer.The only thing that I am looking for is to center two words

相关标签:
7条回答
  • 2020-12-01 22:03

    These times full centering is best achieved using either flexbox or grid layout. So if we just want to center some element within its parent we do something like this:

    HTML

    <div class="parent">
       <div class="child">Some Stuff</div>
    </div>
    

    CSS

    .parent {
        display: flex;
        justify-content: center;
        align-items: center;
        align-content: center;
    }
    
    .child {
        text-align: center;   /* If we want the child element's content horiz centered within its own container */
    }
    
    0 讨论(0)
提交回复
热议问题