如何将div标签放在中心屏幕中

时间:2019-03-26 21:44:14

标签: html css

我想在中心屏幕上显示div,实际上是在中心显示div标签,但是当我设置更多数据时,它会将div标签移到下屏

好结果

enter image description here

不良结果-不在中心屏幕

enter image description here

CSS

/* start set fonts */
* {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
}

/* start general */
html body {
    background-color: #181333;
}

/* start container class */
.container {
    width: 100%;
    background-color: #1e1939;
    position: absolute;
    top: 50%;
    margin: auto;
}

/* start title class */
.title {
    display: block;
    margin: 5px;
    padding: 5px;
    color: #fefefe;
    text-align: center;
    letter-spacing: 5px;
}

/* start main line class */
.main_line {
    display: block;
    width: 5%;
    margin: auto;
    border: 1px solid #9d0dab;
}

/* start description class */
.description {
    width: 25%;
    display: block;
    margin: 5px auto 5px auto;
    padding: 5px;
    color: #6f64a8;
    text-align: center;
}

/* start person class
.person {
    width: auto;
    display: block;
    text-align: center;
}

.photo {
    display: inline-block;
    margin: 10px;
}
*/

HTML

<body>
<div class="container">
    <h1 class="title">OUR TEAM</h1>
    <hr class="main_line">
    <p class="description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
        labore et dolore magna aliqua. Lorem ipsum dolor sit amet et dolore aliqua.</p>
</div>
</body>

底部屏幕上需要一些空间,我希望div每次都位于中心屏幕................................ ...................................................

0 个答案:

没有答案