为什么 justify-content: space-between; 不起作用?

huangapple go评论66阅读模式
英文:

Why justify-content: space-between; doesn't work?

问题

It seems like you're asking for a translation of the code-related text without the code itself. Here's the translation:

"你知道我哪里犯了错吗?似乎space-between没有起作用。我应该添加额外的内边距来修复它,还是使用不同的显示方法?我一直在按照教程操作,但仍然找不出问题在哪。非常感谢任何建议。"

"应该看起来像这样"
"但实际上是这样的"

英文:

Do you have any idea where did I make a mistake? Seems like space-between doesn't do its job. Should I add additional padding to fix it or use a different display method? I was following a tutorial, but sill can't figure out where is the problem. Would be grateful for any suggestions

为什么 justify-content: space-between; 不起作用?
should look like this
为什么 justify-content: space-between; 不起作用?
But it looks like this

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

:root {
  --primary-color: #013456;
  --accent-color: #fad405;
}

.header {
  display: flex;
  justify-content: space-between;
  padding-top: 81px;
  max-width: 1231px;
  margin: 0 auto;
  font-family: &quot;Istok Web&quot;;
  text-align: right;
}
.header span {
  font-weight: 700;
  font-size: 40px;
  margin-right: 10px;
  color: var(--primary-color);
}

.header-title {
  margin: 0;
  display: flex;
  align-items: center;
}

.header .plane-ico {
  color: var(--accent-color);
}
.header-navigation {
  display: flex;
  align-items: center;
  height: 52px;
  margin-right: 5px;
}

.header-navigation a {
  text-emphasis: none;
  margin-left: 29px;
  color: var(--primary-color);
  font-size: 36px;
  font-weight: 500;
  text-decoration: none;
}

.header .menu-ico,
.header .close-ico {
  display: none;
}

.header .close-ico {
  color: var(--accent-color);
}

<!-- language: lang-html -->

 &lt;header class=&quot;header&quot;&gt;
      &lt;h2 class=&quot;header-title&quot;&gt;
        &lt;span&gt;Matt Ridd&lt;/span&gt;
        &lt;i class=&quot;fa fa-lg fa-paper-plane plane-ico&quot;&gt;&lt;/i&gt;
        &lt;nav id=&quot;header-navigation&quot; class=&quot;header-navigation&quot;&gt;
          &lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;
          &lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;
          &lt;a href=&quot;#&quot;&gt;Books&lt;/a&gt;
          &lt;a href=&quot;#&quot;&gt;Blog&lt;/a&gt;
          &lt;a href=&quot;#&quot;&gt;Home &lt;/a&gt;
        &lt;/nav&gt;
        &lt;i onclick=&quot;toggleMenu(&#39;block&#39;)&quot; class=&quot;fa fa-bars menu-ico&quot;&gt;&lt;/i&gt;
        &lt;i
          onclick=&quot;toggleMenu(&#39;none&#39;)&quot;
          id=&quot;close-ico&quot;
          class=&quot;fa fa-times-circle close-ico&quot;
        &gt;&lt;/i&gt;
      &lt;/h2&gt;
    &lt;/header&gt;

<!-- end snippet -->

答案1

得分: 2

尝试将 "header-title" 的宽度设置为 width: 100%;,并将 "header" 类中的 justify-content: space-between; 移至 "header-title",此外 "header-title" 应该是一个 div。

这是一个可运行的示例

英文:

Try giving "header-title" width: 100%;, and shifting justify-content: space-between; from the "header" class to "header-title", furthermore "header-title" should be a div.

Here's a working example

huangapple
  • 本文由 发表于 2023年5月11日 18:02:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定