HTML5 - 如何添加容器?

时间:2017-05-24 10:19:30

标签: html css

我是网络开发的新手,所以只需要一些帮助。

我在标题1和标题2后面创建了框,我不知道如何对齐它们?我不熟悉div。到目前为止。

html

<h1>Pitbull Publo's Photogallery </h1>

<h2>A photo gallery of the worlds CUTEST Pitbull, from Puppy to Beast.</h2>

它们位于样式标记之间:

        h1 {
            color: #992343;
            width: 700px;
            height: 50px;
            background-color: #F7EF84;
            border: 1px ridge #df80ff;
            position: center;
            text-align: center;
            }

        h2 {
            color: #992343;
            width: 700px;
            height: 75px;
            background-color: #F7EF84;
            border: 1px ridge #df80ff;
            text-align: center;
            }

我需要为盒子创建一个容器。请帮忙!

1 个答案:

答案 0 :(得分:1)

尝试使用margin:0 auto;以你的标题为中心

 h1 {
        color: #992343;
        width: 700px;
        height: 50px;
        background-color: #F7EF84;
        border: 1px ridge #df80ff;
        position: center;
        text-align: center;
        margin: 0 auto;
        }

    h2 {
        color: #992343;
        width: 700px;
        height: 75px;
        background-color: #F7EF84;
        border: 1px ridge #df80ff;
        text-align: center;
        margin: 0 auto;
        }
相关问题