1
I’m putting together a project with Bootstrap
but I am facing some problems, one of them is the navbar disappearing when the resolution decreases. The other is I can’t write a title right in the middle of the screen.
Navbar with a problem.
HTML
<header id="header">
<div id="header-overlay"></div>
</header>
<div id="col-md-12">
<nav class="navbar navbar-expand-md fixed-top py-3 box-shadow mt-5">
<a href="index.html" class="navbar-brand">LOGO</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Abrir Navegação">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link text-white" href="#sobre">Sobre</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#solucoes">Soluções</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#contato">Contato</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">PT</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">EN</a>
<a class="dropdown-item" href="#">ES</a>
</div>
</li>
<li class="nav-item ml-3">
<button type="button" class="btn btn-outline-light btn-lg">Entrar</button>
</li>
</ul>
</div>
</nav>
</div>
CSS
/*Header*/
#header {
background: url("../img/header-bg.jpg");
background-size: cover;
background-position: center;
position: relative;
top: 0;
bottom: 0;
height: 90%;
z-index: -10;
}
#header-overlay {
position: absolute;
background-color: rgba(0, 0, 0, 0.4);
top: 0;
bottom: 0;
height: 100%;
width: 100%;
z-index: -5;
}
Another problem I’m facing is that I need to write a text in the middle of this screen but when you write it continues on the side of navbar
and get shot of tag nav
he writes below, I need to put on the image the text and when the image ends start the content of the site.
I need the text to be inside the image, like a presentation, then start the content.
– Guilherme Rigotti
And as you can see in my css I left the image with 100vh, because it was the only way I could display it without cutting, however 100vh is very large, I need it to be smaller but not cut.
– Guilherme Rigotti
@Guilhermerigotti looks there the code I made an edit, your H1 text has to stay inside the header. and then just adjust with a top on it. On the image actually she is 90% of the height...
– hugocsl
about the image was my trip, I’ve seen here that’s correct. I’ll try to put the text now.
– Guilherme Rigotti
@Guilhermerigotti he needs css tb, look at the code, I left at the end the CSS for this H1
#header h1 {
 position: relative;
 top: 45%;
}
and html is inside the div<header id="header"> ... <h1> </header>
– hugocsl
Fixed, my haha mistake. thank you very much man
– Guilherme Rigotti
@Guilhermerigotti take young, qq doubt we are in the area!
– hugocsl
Since you asked, how do I position a
a
to suit any resolution, because the way I’m doingpadding
in your hand is not rolling.– Guilherme Rigotti
It comes after the header texts, a button underneath them, the texts are already ok.
– Guilherme Rigotti
Type that after the H1 text you want a tag
<a>
to be able to make a btn etc is this?– hugocsl
And like there’s no way I can click my button, because to do the overlay I used a
z-index
in theheader
and in theoverlay
to put it there, the option would be to put the button inside thenav
?– Guilherme Rigotti
That’s right @hugocsl
– Guilherme Rigotti
Was there no way I could do all this using bootstrap ? An overlay on the header image with a navbar on top and a text in the center, all using a fixed image size, for example I don’t want the image of its full size, but I don’t want to cut it, I just need to decrease it in css.
– Guilherme Rigotti
I don’t know if you understood what I needed
– Guilherme Rigotti
@Guilhermerigotti face understood yes, the negative z-index does not leave the element clickable! The truth is that this header yours with bootstrap is not well formatted no. I mean the structure in HTML, that’s why you need to do so much "nice" there... I think you should take advantage that you are at the beginning and stop half an hour to see the documentation of the Bootstrap Grid. It will help you A LOT!!
– hugocsl
I even think I can solve this. Taking the text from Header. But to leave it there again we will have to do another "way". Way that would be much better to do if you were with BS4 Grid straight. I think you can open another question, talk about this problem of Z-index and link, and ask for help with Grid, saying that the way it is you are having alignment problems and the link is inaccessible etc... Then I or another member can help you better.
– hugocsl
If you want to fix the text in the same gambit you can put the H1 outside Heade. And change H1’s CSS to that:
h1 {
 position: absolute;
 top: 45%;
 left: 50%;
 transform: translateX(-50%);
}
– hugocsl
I think I better redo it then, because if it’s not going to get Gambi on top of Gambi. But you have some idea of how to make the image in the format I need with bootstrap ?
– Guilherme Rigotti
@Guilhermerigotti yes vc can use a container-Fluid, or a jombotron from Boostrap 4 and put in it a background-image and the text inside etc. It’s not very secret. You should even be able to take advantage of your navbar, the problem is the organization of html and the use of the grid...
– hugocsl