gpt4 book ai didi

html - 中心部分?

转载 作者:太空宇宙 更新时间:2023-11-03 23:46:26 25 4
gpt4 key购买 nike

为什么我的“部分”没有正确居中?

我认为应该这样做:

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;
}

最佳答案

将此添加到 CSS:

section article {margin: 0 auto;}

这意味着“将 0 垂直边距和 auto 水平边距应用到每个 articlesection 的 child ”。 ( JSFiddle )

你的 article s 小于 section 的宽度, 所以你必须居中对齐 article也是。

关于html - 中心部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21434007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com