html - 如何在有 Angular Material 中将 Logo 居中对齐?

标签 html css angular flexbox angular-material

我正在制作一个顶部带有工具栏的 Angular 应用程序。

最后放置了一个左侧菜单按钮、 Logo 和一个按钮以及一个文本。

问题:

Here the logo at center is not center to the toolbar but it is center to the first menu button and the other button after logo text.

要求:

The logo at the center needs to be center for the entire toolbar no matter what is placed next to it.

工作 Stackblitz:

https://stackblitz.com/edit/material-flex-toolbar-21bjwf

最佳答案

只需将工具栏设置为position: relative 并将 Logo 放置在

.logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

这样,无论怎样,logo 都会在中间。当然,不要忘记将 Action 始终保持在右侧(将 margin-left: auto 添加到 Action 中或将 justify-content: space-between 添加到整个 Action 中)工具栏)

关于html - 如何在有 Angular Material 中将 Logo 居中对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62171669/

相关文章:

javascript - 在 Typescript 中以编程方式折叠 Bootstrap 导航栏

javascript - 我应该为 JS 事件触发器使用哪个 HTML5 标签

html - 仅在页面上显示内容

javascript - 如何设置光标: hand for jquery data table

html - 为什么 ul li float left 属性不应用于 li 的第一个 child

python - 传递多个参数返回 'Response' (python)

angular - Apple Pay 与 Angular 的集成

Javascript 控制台应用程序?

html - 如何设置 HTML 中显示的 XML 样式?

javascript - 我怎样才能在每个按钮上方居中放置一个长字符串?