gpt4 book ai didi

html - 图像居中,如何向下移动?

转载 作者:太空宇宙 更新时间:2023-11-04 15:30:33 25 4
gpt4 key购买 nike

我正在制作单页网站。对于“较低”的页面,我将图像作为标题。我可以使用

img
{
display:block
margin-left:auto
margin-right:auto
width:400px
}

但是,我要求它低一点。我尝试添加一个 margin-top,但它似乎为整个页面添加了一个边距(页面变长了?)。然而,图像在我页面上的位置并没有改变。知道出了什么问题吗?

这是一些 HTML:

<body>
<div id="nav">
<ul>
<li><a class="scroll" href="#about">ABOUT</a></li>
<li><a class="scroll" href="#portfolio">WORK</a></li>
<li><a class="scroll" href="#contact">CONTACT</a></li>
</ul>
</div>

<!-- Landing Page-->
<div id="landing">
<img src="front.png" alt="Cover Page">
</div>
<!-- About -->
<div id="page1">
<a id="about"></a>
<img src="Who.png" alt="About Me">
<p>
That sweet tailpipe of yours did have me charmed. It put a spell on me, but all the ass magic in Mexico can’t change Kenny Powers from his core beliefs. I’m not an ass man... I’m a tit man. I like big ass boobs — now, and forever... I’m not like a black guy, Vida...
</p>
</div>

<!-- Work -->
<div id="page2">
<a id="portfolio"></a>
<div id="container">
<a class="fancybox" href="portfolio1.jpg" title="'Consumed' </br>Digital/Print Work"><img src="portfolio1s.png"/></a>
</div>

</div>

<!-- Contact -->
<div id="page3">
<a id="contact"></a>
<img src="Contact.png" alt="Contact Information">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</body>

我说的标题是下页的标题,而不是第一个元素。所以我不确定为什么整个页面都在向下移动。

最佳答案

看看相对定位是否适合你:

position: relative;
top: 10px;

关于html - 图像居中,如何向下移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14507950/

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