使用CSS将元素放在另一个图像的顶部
我有此代码:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="https://toast-shop.opplayz.repl.co/images/logo">
<title>Toast Discord Bot</title>
</head>
<style>
body {
background-image: linear-gradient(to right, #cfd9f2, #A5B8E7, #cfd9f2);
}
.profile{
margin: 0 auto;
position: relative;
display: inline-block;
}
.profilelogo{
width: 25vw;
height: 25vw;
display: inline-block;
float: left;
}
.profileinfo{
font-family: arial;
}
</style>
<body>
<div class="profile" id="profile">
<img src="https://toast-shop.opplayz.repl.co/images/logo" class="profilelogo" id="profilelogo">
<div class="profileinfo">
<h1>Toast Shop</h1>
<h2>A Discord Bot that brings fun to your server</h2>
</div>
</div>
</body>
我希望我的图像和文字看起来像这样:
在较大的屏幕上,H1和H2元素在图像停留在中间时进入页面顶部。我希望文本与图像,水平智慧保持一致。我该如何使用CSS做到这一点?
I have this code:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="https://toast-shop.opplayz.repl.co/images/logo">
<title>Toast Discord Bot</title>
</head>
<style>
body {
background-image: linear-gradient(to right, #cfd9f2, #A5B8E7, #cfd9f2);
}
.profile{
margin: 0 auto;
position: relative;
display: inline-block;
}
.profilelogo{
width: 25vw;
height: 25vw;
display: inline-block;
float: left;
}
.profileinfo{
font-family: arial;
}
</style>
<body>
<div class="profile" id="profile">
<img src="https://toast-shop.opplayz.repl.co/images/logo" class="profilelogo" id="profilelogo">
<div class="profileinfo">
<h1>Toast Shop</h1>
<h2>A Discord Bot that brings fun to your server</h2>
</div>
</div>
</body>
I want my image and text to look like this:
On larger screens, the h1 and h2 elements goes to the top of the page while the image stays in the middle. I want the text to align with the image, horizontal wise. How could I do this with css?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)