图像上重叠的标题[关闭]

问题描述 投票:0回答:1

我正在尝试重叠标题和图像,但我无法让它工作

我尝试使用 1 div 中的所有内容并使用相对位置使它们重叠,但它不起作用 我也尝试使用 z 索引,但它仍然不起作用

这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home</title>
    <link rel="stylesheet" href="home.css">
</head>
<body>
    <div class="header">
        <h1>Pixelcyber</h1>
        <nav>
            <a href="home.html" style="text-decoration:none">Home</a>
            <a href="portfolio.html" style="text-decoration:none">Portfolio</a>
            <a href="projects.html" style="text-decoration:none">Projects</a>
            <a href="contacts.html" style="text-decoration:none">Contacts</a>
        </nav>
    </div>
    <h1>Coder</h1>
    <p>4 years experience</p>
    <div class="wp">
        <img src="luffy.png" alt="luffy">
    </div>
</body>
</html>
html css
1个回答
0
投票

你可以这样做

position: absolute;
top: 0;
left: 0;

就像这里一样 https://stackblitz.com/edit/stackblitz-starters-rtpd4i?file=index.html

© www.soinside.com 2019 - 2024. All rights reserved.