How to fix the position of a header independent of the screen size?

Asked

Viewed 341 times

0

Basically I’m building a burger menu and the same has this blue bar as shown on the screen below: inserir a descrição da imagem aqui

But the more I press this screen, the smaller the size of this bar, which ends up hiding the button: inserir a descrição da imagem aqui

Squeezing harder

inserir a descrição da imagem aqui

Is there any way to make the CSS of this element not let it do this?

I have the `Menu.js component

East with:

const contentHeader = (
      <div id="headerBlock">
        {!this.state.docked && (
          <button
            variant="outline-primary"
            onClick={this.menuButtonClick}
            href="#"
            style={styles.contentHeaderMenuLink}
            className="buttonMenu"
          >
            <i class="material-icons">menu</i>
          </button>
        )}
      </div>
    );

     return (
       <Sidebar {...sidebarProps}>
         <MaterialTitlePanel title={contentHeader}></MaterialTitlePanel>
       </Sidebar>
     );

And inside the component MaterialTitlePanel have these Styles:

const styles = {
  /*Propriedades do Pai Header*/
  root: {
    fontFamily:
      '"HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif',
    fontWeight: 300,
    marginTop: "5%"
  },
  /*Propriedades do Header*/
  header: {
    backgroundColor: "#03a9f4",
    color: "white",
    padding: "5px",
    fontSize: "1.5em"
  }
};

In the view which encompasses the desired display have these elements:

<div style={{position: "fixed",overflow: "hidden",top:0, width: "100%", zIndex:10}}>
    <header>
        <Topo loading={this.props.loadingCardsConsulta}/>
    </header>
</div>
<div>
    <Menu />
</div>

I have tested several solutions and nothing has helped.

  • Guy takes a test, switches this marginTop: "5%" for a pixel value, or even put 0 to see what happens, it’s just a kick to test even

1 answer

0

As far as I know, there’s a way to use something like

header: {
    position: fixed,
    backgroundColor: "#03a9f4",
    color: "white",
    padding: "5px",
    fontSize: "1.5em"
  }
};

To make it easier, you can create a . css file and put a class into the header and shape it into the css file

  • I’ll test it to see if it makes a difference. Edit: So, using the position Fixed, it got much smaller (which is not a problem), but still it goes up and into the component above it, keeping the problem, I’ll try to put position Fixed in the whole Menu component and see what happens.

  • I was going to say this, to put in the Menu component, or in the property you say would be Father Header

  • unfortunately regardless of where I place the property position: "Fixed", still continues with the main problem, I will investigate further what may be.

  • Try something with position and go with Static, relative, Fixed, Absolute and Sticky. I will leave this link for you to have a look: https://www.w3schools.com/css/css_positioning.asp and also https://developer.mozilla.org/en-US/docs/Web/CSS/position

  • Okay, I’ll take a look, see if something there helps me

Browser other questions tagged

You are not signed in. Login or sign up in order to post.