首页 > 解决方案 > Material-UI 中的 TextField 进入页眉区域

问题描述

滚动页面时,TextField页面上的header区域可见。header是用 css 创建的,我使用的是TextFieldfrom material-ui

我以前从未使用 css 创建过标题。在创建标头时,是否可能必须包含一些代码?请参阅下面的代码。

.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #02ABED;
    height: 56px;
}

.toolbar__navigation {
    display: flex;
    height: 100%;
    align-items: center;
    padding: 0 1rem;
}

.toolbar__logo a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
}

.spacer {
    flex: 1;
}

.toolbar_navigation-items ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.toolbar_navigation-items li {
    padding: 0 0.5rem;
}

.toolbar_navigation-items a {
    color: white;
    text-decoration: none;
}

.toolbar_navigation-items a:hover,
.toolbar_navigation-items a:active {
    color: black;
}

标签: cssreactjstypescriptmaterial-ui

解决方案


如果有人有同样的问题,我通过设置来解决这个问题z-index,请参见下面的代码:

.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #02ABED;
    height: 56px;
    z-index: 1;
}

推荐阅读