我如何适应和自动移动和缩放两个标题之间的图像?



我想在两个标题之间放置一个徽标图像,并调整它的大小和移动,使它保持相对于文本。

body{
background-color: black;
}
.logotext{
padding: 25px;;
font-family: abnes;
color:white;
}
#h1{
float: left;
}
#h2{
float: right;
}
#logo{
float:inherit;
}
<head>
<link rel="stylesheet" href="main.css">
<body>
<div class=logotext>
<h1 id="h1">Huron</h1>
<h1 id="h2">Interplanetary</h1>
<img id=logo src="https://dummyimage.com/600x600/000/fff">
</div>
</body>
</head>

我想让它看起来像这样:休伦0行星际(其中0为标识图像)。

简单的问题,但我正在学习。

我把justify-content: space-between添加到你的.logotext中,这样当你放大或缩小时它就会保持在中心。确保也加入display: flex,否则justify-content将不起作用。

.logotext{
padding: 25px;
font-family: abnes;
color:white;
display: flex;
justify-content: space-between;
}

希望这是你正在寻找的。您可以在这里查看flexbox

的完整解释。