中心部分?

xoxo_tw

为什么我的“部分”不能正确居中?

我认为应该这样做:

section{
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

这次出了什么问题?

HTML:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
<title>LifeSymb.com</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<section>
    <article id="intro" class="scrollBlock">
            <h1>HOMES on the WEB</h1>

            <p>WHats going on, somekinda test text
            Likely to go and whats going to happen, hoihfedfh
            Fancy scrolling is going to Happen !!!</p>
    </article>
    <article id="slide2" class="scrollBlock">
            <h2>SLIDE 2</h2>

            <a href="http://google.com" id="photoSlide2"><img src="images/block2.png" alt="" /></a>
            <p>Text TUTYUYIUYOIUOIUiihjihiohiuhiuhuhuhuohoiuhoiyuoiuy</p>
            <p class="btn"><a href="http://google.com">Vist HERE!!!</a></p>
    </article>
    <article id="dog" class="scrollBlock">
            <h2>My dog has his own website</h2>

            <p>That's right! My dog Dog has his very own website full of cute doggy photos right from being a pup.<br/>
            <strong>Check out Jake's website at <a href="http://google.com">http://google.com</a></strong></p>
    </article>
</section>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="scripts/libs/jquery.scrollorama.js"></script>
<script src="scripts/scrollScript.js"></script>
</body>
</html>

CSS:

body{
    font: 18px/30px Sans-serif;
    color: black;
    background:url('../images/bodyBG.png');
}

section{
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.scrollBlock{
    width: 70%;
}

#intro{
    background: lightgreen url(../images/dragon.jpg) left no-repeat;
    /*background-size: cover;*/
}

    #intro h1{
        width: 677px; height: 122px;
        background: url(../images/btn_intro.png);
        text-indent: -9999px;
        position: relative;
        top: 145px;
        left: 0;
    }
    #intro p{
        position: relative;
        top: 200px;
        left: 350px;
        width: 508px;
        margin: 0 0 30px 0;
    }
    #intro p:nth-child(2){
        font-weight: bold;
    }


#slide2{
    background: lightpink url(../images/texture_purple.png);
}


#dog{
    background: black url(../images/dog.jpg)no-repeat;
    background-size: cover;
    padding-top: 400px;
}
    #dog h2{
        opacity: 0;
    }
克里斯蒂娜·克里斯蒂亚(Cristina Cristea)

将此添加到CSS:

section article {margin: 0 auto;}

这意味着“将0垂直边距和auto水平边距应用于每个article作为其子级的边距section”。JSFiddle

您的articles小于的宽度section,因此您也必须将articles居中对齐

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

numpy图片的裁剪中心部分

掩盖电子邮件ID的中心部分

选择游戏中心部分目的地

HTML-Bootstrap-如何裁剪图像的中心部分

如何在iOS中裁剪大图像的中心部分?

仅显示图像的中心部分,点击显示完整图像

中心部门

如何仅在文本的中心部分添加背景颜色?像粗删除线,但只在背景中

放大和保存matplotlib geopandas图中感兴趣的中心部分

如何在Java中切片或复制矩阵的中心部分

mailchimp API中OAuth身份验证中的数据中心部分

在Windows 10 Universal App中将命令绑定到中心部分标题单击

旋转或调整大小时,如何通过中间中心部分而不是左上角来维护 UIScrollView 的 contentOffset?

文件的核心部分是什么?

MarkLogic脱机数据中心部署问题

如何在matplotlib中删除圆环图的偏心部分?

.NET核心部分视图土耳其语字符错误

代号容器中的一个中心部件

Azure IoT中心部署:默认事件缺少集线器端点“ operationsMonitoringEvents”

AutoOpen任务窗格带有通过Office 365管理中心部署的加载项

IoT 中心部署清單:可以指定模塊標識標籤嗎?

如何获得视差有效的核心部分-这就是诀窍?

BorderPane中心与其他部分重叠

在容器中以文本为中心的部分

需要在中心显示所有3个部分

如何水平对齐超出身体边缘的部分到中心?

如何使关键字固定在中心,而左右部分则保持在中心附近?

将dotnet核心部署到Heroku

使用 flexbox,菜单栏将身体的其余部分推离中心