如何在居中的图像旁边放置文本?

How to place text next to an image centred?

抱歉,我知道这是一个非常基本的问题,但我不知道如何在垂直居中的图像旁边放置文本。我已经搜索了如何做,并尝试了几种不同的方法,但我似乎无法找到一种有效的方法。我在想,也许我犯了一个我在代码中一直忽略的错误。我是新手,只是想看看我能在多大程度上应用我所学的知识。谢谢,这是我的代码。

html, body {
  margin: 0px;
  padding:0px;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  background-image: url("https://cdn.pixabay.com/photo/2015/12/03/08/50/paper-1074131_1280.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;

  height: 100%;
  opacity: 75%;

}

.header {
  display: flex;
  align-items: center;
  justify-content: center;
}



.image {
  flex-basis: 40%;
  height: 20px;
  width:35px;
  vertical-align: middle;
}

.webtitle {
  font-size: 30px;
  padding-left: 5px;
  vertical-align: middle;
  font-weight: bold;


}
<!DOCTYPE html>
<html>
  <head>
    <title>Home - Historically Speaking</title>
  <link href="D:\Programming\HTML\First Website\syle1.css" type="text/css" rel="stylesheet" />
  </head>

  <body>
    <div class="Header">
      <div class="Logo">
        <img src="https://i.imgur.com/Cm5P5vP.jpeg" width="250" height="200" align="left"/>
      </div>
      <div class="webtitle">
        <p> Historically Speaking </p>
      </div>
    </div>


  </body>
</html>

首先将您的 class 名称更正为 .Header 到您的样式表中。其次,为您的页眉提供高度并将 .webtitlt 显示为 flex 并将内容对齐到中心

    .webtitle {
  font-size: 30px;
  padding-left: 5px;
  vertical-align: middle;
  font-weight: bold;
  display:flex;
  justify-content:center;


}

.Header {
  display: flex;
  align-items: center;
  height:200px;
}

你根本不需要vertical-align: middle;,容器的flex设置足以满足你的需求,你只需要注意class名称:headerHeader - 区分大小写...:[=​​15=]

html,
body {
  margin: 0px;
  padding: 0px;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  background-image: url("https://cdn.pixabay.com/photo/2015/12/03/08/50/paper-1074131_1280.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  height: 100%;
  opacity: 75%;
}

.Header {
  display: flex;
  align-items: center;
  justify-content: center;
}

.image {
  flex-basis: 40%;
  height: 20px;
  width: 35px;
}

.webtitle {
  font-size: 30px;
  padding-left: 5px;
  font-weight: bold;
}
<!DOCTYPE html>
<html>

<head>
  <title>Home - Historically Speaking</title>
  <link href="D:\Programming\HTML\First Website\syle1.css" type="text/css" rel="stylesheet" />
</head>

<body>
  <div class="Header">
    <div class="Logo">
      <img src="https://i.imgur.com/Cm5P5vP.jpeg" width="250" height="200" align="left" />
    </div>
    <div class="webtitle">
      <p> Historically Speaking </p>
    </div>
  </div>


</body>

</html>