Bootstrap navbar collapse opens in the wrong place - html

Navbar collapsed menu fits perfectly to the navbar in Safari browser and occupy full width of the viewport. However, in other browsers collapsed navbar is getting smaller and sticks to the very top of the page. Looks like it is not connected to the navbar itself and drops down from another reference point. Is this a browser prefix issue or something entirely wrong with my bootstrap structure?
.navbar {
height: 60px;
padding: 0;
margin: 0;
border-bottom: .1px solid black;
background: #ffffff;
}
.navbar-nav {
margin-top: 1.5em;
}
.navBut {
margin: 20px 0;
}
.navButBut {
border: 1px solid red;
}
.navbar-toggle {
border-color: black !important;
color: snow;
height: 30px;
width: 45px;
padding: 2px 5px 0;
margin: 15px 8% 15px 0;
}
.navbar-toggle:hover {
background-color: transparent !important;
}
.dropbut {
font-size: 1.5em;
color: black;
}
.fa-korvue {
color: #962715;
font-size: 3.5em;
line-height: -45%;
float: left;
margin: 5px 8% 0 12%;
}
.link_icon, .link_icon:link, .link_icon:visited, .link_icon:active {
color: #1e1e20;
padding: 0;
margin-right: 20px;
font-family: 'Arsenal', sans-serif;
font-size: 1.2em;
text-decoration: none;
outline: 0;
cursor: pointer;
background: transparent;
}
#collapse_menu {
margin-top: 1.2em;
}
#collapse_menu li a {
padding: 3px 8px;
margin-right: 5px;
border-radius: 3px;
}
#collapse_menu li a:hover {
background-color: rgba(0, 0, 0, 0.2) !important;
}
.hidden-xs {
margin-right: 18px;
}
#phone_handset {
color: black;
font-size: 1.7em;
vertical-align: 10%;
text-decoration: none;
outline: 0;
transition: 1s;
}
#phone_num {
display: inline;
margin-right: 4em;
vertical-align: 20%;
font-size: 1.3em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<header>
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="fa fa-th dropbut"></span>
</button>
<i class="fab fa-korvue"></i>
<div class="collapse navbar-collapse" id="myNavbar">
<ul id="collapse_menu" class="nav navbar-nav text-center">
<li><a class="link_icon scroll" name="1" href="#top_page_scroll">Начало</a></li>
<li><a class="link_icon scroll" name="2" href="#about_me_scroll">Обо мне</a></li>
<li><a class="link_icon scroll" name="3" href="#portfolio_scroll">Услуги</a></li>
<li><a class="link_icon scroll" name="4" href="#pricing_scroll">Цены</a></li>
<li><a class="link_icon scroll" name="5" href="#contact_me_scroll">Регистрация</a></li>
</ul>
<div class="navbar-nav navbar-right vertical-align">
<a id="phone_handset" class="fas fa-phone-volume hidden-xs" href="#"></a>
<a id="phone_num" class="link_icon hidden-xs" href="#">110-223-456-78</a>
</div>
</div>
</div>
</nav>
</header>

I finally fixed this issue. If you wrap navbar-toggle with <div class=“navbar-header”> then everything starts to work as expected. Now collapsed navbar occupies full width and sits in the right place. Thank #fnostro for the valuable tips.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<header>
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="fa fa-th dropbut"></span>
</button>
<i class="fab fa-korvue"></i>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul id="collapse_menu" class="nav navbar-nav text-center">
<li><a class="link_icon scroll" name="1" href="#top_page_scroll">Начало</a></li>
<li><a class="link_icon scroll" name="2" href="#about_me_scroll">Обо мне</a></li>
<li><a class="link_icon scroll" name="3" href="#portfolio_scroll">Услуги</a></li>
<li><a class="link_icon scroll" name="4" href="#pricing_scroll">Цены</a></li>
<li><a class="link_icon scroll" name="5" href="#contact_me_scroll">Регистрация</a></li>
</ul>
<div class="navbar-nav navbar-right vertical-align">
<a id="phone_handset" class="fas fa-phone-volume hidden-xs" href="#"></a>
<a id="phone_num" class="link_icon hidden-xs" href="#">110-223-456-78</a>
</div>
</div>
</div>
</nav>
</header>

Related

How can I show my navbar horizontally without affecting the background img and hero content

I'm trying to create a landing page but I'm finding it hard to place my navbar and still keep my hero content intact the way it is. I tried using flexbox but it seems it's not working when I position my content relative and use bottom 50% to bring the nave bar to the corner.
body, html {
height: 100%;
margin: 0;
font-size: 20px;
}
.hero-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("building.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.btn {
text-transform: capitalize;
font-size: 1rem;
border-radius: 1rem;
border-color: white;
}
.btn:hover {
background-color: aqua ;
border-color: aqua;
}
.main {
position: relative;
display: flex;
}
li {
list-style-type: none;
display: flex;
}
li a {
text-decoration: none;
}
<body>
<div class="hero-image">
<div class="hero-text">
<h1>Welcome to ZERG</h1>
<p>Where we Strive for a better Future</p>
<button class="btn">Find out More</button>
</div>
</div>
<nav class="main">
<ul>
<li>Home</li>
<li>Pricing</li>
<li>Contact </li>
</ul>
</nav>
</body>
Do you mean a bottom navbar? Or a weird horizontally in the middle one? Here is an example of bottom navbar. Run the snippet and put in full page.
body,
html {
height: 100%;
margin: 0;
font-size: 20px;
}
.hero-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("building.jpg");
height: 100vh;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.btn {
text-transform: capitalize;
font-size: 1rem;
border-radius: 1rem;
border-color: white;
position: static;
margin-bottom: 100px;
}
.btn:hover {
background-color: aqua;
border-color: aqua;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<body>
<div class="hero-image">
<div class="hero-text">
<h1>Welcome to ZERG</h1>
<p>Where we Strive for a better Future</p>
<button class="btn">Find out More</button>
</div>
</div>
<nav class="navbar fixed-bottom navbar-expand-sm navbar-dark bg-dark">
<a class="navbar-brand" href="#">Bottom navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropup">
<a class="nav-link dropdown-toggle" href="https://getbootstrap.com/" id="dropdown10" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropup</a>
<div class="dropdown-menu" aria-labelledby="dropdown10">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>

Why Navbar Collapse isn't working for me using Bootstrap? [duplicate]

This question already has answers here:
Navbar dropdown (collapse) is not working in Bootstrap 5
(11 answers)
Closed 1 year ago.
I'm having a problem with Bootstrap, navbar collapse button doesn't work I tried everything possible and followed every mentioned step on the Tutorial I was watching. How can I make it work for me without changing the Signup and Login buttons?
Please help me.
Here's my html code:
body{
background-color: #F7F7F7;
font-family: Montserrat-Medium;
}
ul{
list-style-type:none;
}
.navbar-brand{
color: black;
font-family: Montserrat-Medium;
margin-left: 150px;
text-align: center;
}
.nav-brand-text{
}
.nav-signup{
background-color: #5E99EF;
color: white;
border: none;
padding: 16px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin-top: 4px;
border-radius: 46px;
}
.nav-signup:hover{
background-color: #4E83CF;
color: #EAEAEA;
}
.nav-login{
border: 5px solid black;
border-color: #5E99EF;
color: #5E99EF;
padding: 11px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin-top: 4px;
border-radius: 46px;
white-space: nowrap;
}
.nav-login:hover{
color: #4E83CF;
background-color: #EAEAEA;
}
.nav-items-row{
margin-right: 150px;
}
<body>
<nav class="navbar navbar-expand-md navbar-fixed-top navbar-light bg-white shadow-sm p-4 mb-5">
<div class="container-fluid">
<div class="nav-header">
<button type="button" class="navbar-toggler position-absolute start-1" data-toggle="collapse" data-target=".navbar-submenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="col-md">
<a class="navbar-brand" href="#">
<img src="res/logo.png" width="40" height="40" class="" alt=""></img><b> Tbadel.ma</b>
</a>
</div>
</div>
<div class="collapse navbar-collapse navbar-submenu">
<ul class="nav nav-items-row position-absolute end-0">
<ul class="col-md">
<li>S'identifier</li>
</ul>
<ul class="col-md">
<li>Se connecter</li>
</ul>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.1/dist/umd/popper.min.js" integrity="sha384-SR1sx49pcuLnqZUnnPwx6FCym0wLsk5JZuNx2bPPENzswTNFaQU1RDvt3wT4gWFG" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/js/bootstrap.min.js" integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc" crossorigin="anonymous"></script>
</body>
In bootstrap5 there is some changes in tag like: data-toggle change to data-bs-toggle
and data-target to data-bs-target
So when use data-bs-target target id of div instead of class.
body{
background-color: #F7F7F7;
font-family: Montserrat-Medium;
}
ul{
list-style-type:none;
}
.navbar-brand{
color: black;
font-family: Montserrat-Medium;
margin-left: 150px;
text-align: center;
}
.nav-brand-text{
}
.navbar-toggler {
z-index: 1;
}
.nav-signup{
background-color: #5E99EF;
color: white;
border: none;
padding: 16px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin-top: 4px;
border-radius: 46px;
}
.nav-signup:hover{
background-color: #4E83CF;
color: #EAEAEA;
}
.nav-login{
border: 5px solid black;
border-color: #5E99EF;
color: #5E99EF;
padding: 11px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin-top: 4px;
border-radius: 46px;
white-space: nowrap;
}
.nav-login:hover{
color: #4E83CF;
background-color: #EAEAEA;
}
.nav-items-row{
margin-right: 150px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<body>
<nav class="navbar navbar-expand-md navbar-fixed-top navbar-light bg-white shadow-sm p-4 mb-5">
<div class="container-fluid">
<div class="nav-header">
<button type="button" class="navbar-toggler position-absolute start-1 collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-submenu" aria-expanded="false">
<span class="navbar-toggler-icon"></span>
</button>
<div class="col-md">
<a class="navbar-brand" href="#">
<img src="res/logo.png" width="40" height="40" class="" alt=""><b> Tbadel.ma</b>
</a>
</div>
</div>
<div class="collapse navbar-collapse" id="navbar-submenu">
<ul class="nav nav-items-row position-absolute end-0">
<ul class="col-md">
<li>S'identifier</li>
</ul>
<ul class="col-md">
<li>Se connecter</li>
</ul>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.1/dist/umd/popper.min.js" integrity="sha384-SR1sx49pcuLnqZUnnPwx6FCym0wLsk5JZuNx2bPPENzswTNFaQU1RDvt3wT4gWFG" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/js/bootstrap.min.js" integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc" crossorigin="anonymous"></script>
</body>

Bootstrap Container Issue

Below you will find my bootstrap 4 code. On the bottom of the code, you will see "why is this section not bellow the video"
I can't seem to figure out why that code is not in a new section below the code.
I know this is a user issue, I just cant seem to figure out why. Any help would be greatly appreciated!
/* font-family: 'Paytone One', sans-serif;
font-family: 'Questrial', sans-serif; */
.questrial {
font-family: 'Questrial', sans-serif;
}
/* .green-back{
background: rgb(215,255,206);
background: linear-gradient(90deg, rgba(215,255,206,1) 5%, rgba(186,202,224,1) 100%);
height: 95vh;
margin: 1em;
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
} */
.navbar-brand {
padding-left: 2%;
}
.logoImg {
height: 2em;
width: auto;
}
video {
/* width: 100% !important;
height: auto !important; */
position: fixed;
top: 50%;
left: 50%;
width: 100vw;
height: auto;
z-index: -100;
transform: translate(-50%, -50%);
}
.navbar {
margin-top: 3vh;
margin: 1em;
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border: 1px solid rgb(230, 230, 230);
}
.space {
margin-left: 2%;
margin-right: 2%;
}
.headBtn {
height: 70%;
margin-top: 2%;
margin-right: 1em;
}
.signUpBtn,
.signInBtn {
margin-right: 30px;
}
#signIn {
background-color: #d7d7d7;
border: 1px solid #7b7b7b;
font: bold;
}
#signUp {
background-color: rgb(145, 145, 145);
border: 1px solid #7b7b7b;
color: white;
}
#media (min-width: 768px) {
.navbar-brand.abs {
position: absolute;
width: 100%;
left: 0;
text-align: center;
}
}
.headingIntro {
font-size: 2vw;
color: #79787A;
padding-top: 10vh;
}
.headingMain {
font-size: 5vw;
color: rgb(65, 65, 65);
}
.headingContent {
font-size: 2vw;
color: rgb(65, 65, 65);
}
.btn-primary {
background-color: rgb(60, 60, 60);
}
.heroButton {
margin-top: 10%;
width: 20vw;
}
.heroButton:hover {
background-color: green;
}
.charityText {
padding-top: 1%;
}
.heroTextBack {
background-color: rgb(245, 245, 245, .8);
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#media (max-width: 576px) {
.heroButton {
margin-top: 10%;
width: 20vw;
}
.headingIntro {
font-size: 4vw;
color: #79787A;
padding-top: 4vh;
}
.headingMain {
font-size: 7vw;
color: rgb(65, 65, 65);
}
.headingContent {
font-size: 4vw;
color: rgb(65, 65, 65);
}
.btn-primary {
background-color: rgb(60, 60, 60);
}
.charityText {
padding-top: 1%;
}
.navbar-brand {
padding-left: 0%;
}
/* .buttonGrp{
display: inline;
} */
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>meetlete: meet your favorite atheletes!</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Paytone+One&family=Questrial&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="./assets/style.css">
</head>
<body>
<div class="conatiner green-back">
<div class="row">
<div class="col-12">
<video playsinline autoplay muted loop>
<source src="https://meetlete.s3-us-west-1.amazonaws.com/FP000091HD01.mp4" type="video/mp4">
<source src="https://meetlete.s3-us-west-1.amazonaws.com/FP000091HD01.mp4" type="video/ogg">
Your browser does not support the video tag.
</video>
<!-- <video playsinline autoplay muted loop
src="https://meetlete.s3-us-west-1.amazonaws.com/FP000091HD01.mp4">
</video> -->
</div>
</div>
<div class="row">
<div class="col-12">
<!-- Navbear -->
<nav class="navbar navbar-light navbar-expand-md bg-light justify-content-center questrial">
<a href="./index.html" class="navbar-brand d-flex w-50 mr-auto">
<img src="./assets/images/meetlete.png" class="logoImg">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon">
</span>
</button>
<div class="navbar-collapse collapse w-100" id="collapsingNavbar3">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">Learn
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact
</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item headBtn">
<button class="nav-link" id="signIn" href="#">Sign In
</button>
</li>
<li class="space headBtn">
</li>
<li class="nav-item headBtn">
<button class="nav-link" id="signUp" href="#">Sign Up
</button>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="container heroTextBack">
<div class="row">
<div class="col-12">
<h2 class="text-center headingIntro questrial">Introducing Meetlete (beta)</h2>
</div>
</div>
<div class="row">
<div class="col-12 text-center">
<h1 class='headingMain questrial'>Meet your favorite athlete!</h1>
</div>
</div>
<div class="row">
<div class="col-1">
</div>
<div class="col-10 text-center questrial">
<h3 class="headingContent">As a fan, how many opportunities do you get to have a real conversation with one of your favorite players or sports personalities?</h3>
</div>
</div>
<div class="row questrial">
<div class="col-3"></div>
<div class="col-3 text-center buttonGrp">
<button type="button" class="btn btn-primary heroButton">Sign Up</button>
</div>
<div class="col-3 text-center buttonGrp">
<button type="button" class="btn btn-outline-success heroButton">Talent</button>
</div>
</div>
<div class="row questrial">
<div class="col-12">
<p class='text-center charityText'>A porition of each Meetlete goes to charity!</p>
</div>
</div>
<div class="row">
<div class="col-12">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">Why is this not bellow the video</div>
</div>
</div>
<!-- <nav class="navbar navbar-expand-md navbar-light bg-light myFont">
<a href="#" class="navbar-brand">
<img src="./assets/images/meetlete-logo-text.png" height="40px" alt="CoolBrand">
</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Right</a>
</li>
</div>
</div>
</nav> -->
<!-- bootstrap js file-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous">
</script>
</body>
</html>
The reason is bcuz yow video tag has a position fixed which means that it does not belongs to the dom

Placing Text over Image

What I am trying to do is make it so that the text can be shown over the image. I put the text in an h1 tag which is inside of a div inside of the body. However, for some reason the changes aren't registering. In-fact, any changes that I make to the text that I want to be in the center of the image, those changes aren't registering at all.
HTML:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<title>Home Page</title>
<script type="text/javascript">
<script src="script.js" charset="utf-8"></script>
</head>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<img src="https://cdn.discordapp.com/attachments/770076532433354783/770076695368564776/vice-logoFlag1.png" width="50" height="50">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" id="homeWording" href="/Users/nixon/Documents/Website Development/Website 1 Project/home.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Gang Database
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">The Ballas</a>
<a class="dropdown-item" href="#">The Families</a>
<a class="dropdown-item" href="#">Los Santos Vagos</a>
<a class="dropdown-item" href="#">Varrios Los Aztecas</a>
<a class="dropdown-item" href="#">Marabunta Grande</a>
</div>
</li>
</ul>
<button class="btn btn-outline-success my-2 my-sm-0" id="logout" type="submit">Log out</button>
</div>
</nav>
<body>
<div class="image">
<img src="https://cdn.discordapp.com/attachments/398526333480599563/720783925395456021/TC21.png" alt="" width="100%" height="350">
<h1>TEXT IN CENTER</h1>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</html>
CSS:
body {
background-color: #212529;
}
.main {
background-color: #77857b;
width: 400px;
height: 400px;
margin: 7em auto;
border-radius: 1.5em;
box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
}
#signInLettering {
font-size: 34px;
font-family: Optima;
padding-top: 40px;
font-weight: bold;
color: #d8e7eb;
font-style: italic;
}
.un {
width: 76%;
color: rgb(38, 50, 56);
font-weight: 700;
font-size: 14px;
letter-spacing: 1px;
background: #d8e7eb;
padding: 10px 20px;
border: none;
border-radius: 20px;
outline: none;
box-sizing: border-box;
border: 2px solid rgba(0, 0, 0, 0.02);
margin-bottom: 50px;
margin-left: 46px;
text-align: center;
margin-bottom: 27px;
font-family: 'Ubuntu', sans-serif;
}
.pass {
width: 76%;
color: rgb(38, 50, 56);
font-weight: 700;
font-size: 14px;
letter-spacing: 1px;
background: #d8e7eb;
padding: 10px 20px;
border: none;
border-radius: 20px;
outline: none;
box-sizing: border-box;
border: 2px solid rgba(0, 0, 0, 0.02);
margin-bottom: 50px;
margin-left: 46px;
text-align: center;
margin-bottom: 27px;
font-family: 'Ubuntu', sans-serif;
}
#homeWording {
padding-right: 50px;
}
.image {
position: relative;
width: 100%;
}
h1 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
In your CSS:
.image {
position: relative;
width: 100%;
}
Possible Solution:
.image {
position: relative;
width: 100%;
text-align: center;
}
See here
Just use flexbox like this
Give a higher z-index to the H1 and change the positioning of the image to absolute.
See codepen https://codepen.io/thewhitegrizzzzli/pen/xxOqdGM
.image {
position: relative;
width: 100%;
display:flex;align-items:center;justify-content:center;
height:350px;
}
.image img {
position:absolute;top:0;
}
h1 {
z-index:10;
}

Changing navbar background color while keeping toggle menu (hamburger)

I would like to have a custom color (#5f788a) for my navbar, however, I understand that in order to have the toggle menu in mobile version, the navbar class must be navbar-light or navbar-dark (according to Bootstrap). This, of course, overrides my custom navbar color and it looks like I have to choose between the hamburger menu OR my custom color.
Things I have tried:
1). Using ! important in CSS to override the styling;
2). Styling with the background-color attribute in CSS;
3). Styling body but this affects rest of site colors, not just navbar.
Here is the CSS:
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
}
h1, h2, h3, h4, h5, h6 {
color: #444444;
}
.bg-steel {
background-color: #5f788a;
}
.site-header .navbar-nav .nav-link {
color: #5f788a;
}
.site-header .navbar-nav .nav-link:hover {
color: #ffffff;
}
.site-header .navbar-nav .nav-link.active {
font-weight: 500;
}
.content-section {
background: #ffffff;
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
margin-bottom: 20px;
}
.article-title {
color: #444444;
}
a.article-title:hover {
color: #428bca;
text-decoration: none;
}
.article-content {
white-space: pre-line;
}
.article-img {
height: 65px;
width: 65px;
margin-right: 16px;
}
.article-metadata {
padding-bottom: 1px;
margin-bottom: 4px;
border-bottom: 1px solid #e3e3e3
}
.article-metadata a:hover {
color: #333;
text-decoration: none;
}
#parent {
list-style: none;
width: 100%;
height: 90px;
margin: 0;
padding: 0;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
}
.article-svg {
width: 25px;
height: 25px;
vertical-align: middle;
}
.account-img {
height: 125px;
width: 125px;
margin-right: 20px;
margin-bottom: 16px;
}
.account-heading {
font-size: 2.5rem;
}
#import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css");
And the of the site:
<body>
<header class="site-header">
<nav class="navbar navbar-default navbar-expand-md navbar-light fixed-top">
<div class="container">
<a class="navbar-brand mr-4" href="/">Company Name (v0.01)</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="/about">About</a>
</div>
<!-- SEARCH BOX-->
<!-- <form class="form-inline my-2 my-lg-0">-->
<!-- <input class="form-control mr-sm-1" id="search_box" type="search" placeholder="Find some stuff..." aria-label="Search" align="middle">-->
<!-- <button class="btn btn-outline-light my-2 my-sm-0 mr-5" type="submit" align="center">Search</button>-->
<!-- </form>-->
<!-- Navbar Right Side -->
<div class="navbar-nav">
{% if current_user.is_authenticated %}
<a class="nav-item nav-link" href="/post/new">New Post</a>
<a class="nav-item nav-link" href="/send_invites">Invite</a>
<a class="nav-item nav-link" href="/account">My Account</a>
<a class="nav-item nav-link" href="/logout"><span class="glyphicon glyphicon-log-in"></span> Logout</a>
{% else %}
<a class="nav-item nav-link" href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a>
<a class="nav-item nav-link" href="/register"><span class="glyphicon glyphicon-user"></span> Register</a>
{% endif %}
</div>
</div>
</div>
</nav>
</header>
Could it be that I should be trying to style the body? If so, wont that affect the rest of the site, not just the navbar? Thanks for your help
navbar-light and navbar-dark are helper classes, what they do is change the colour of the text from white (if navbar-dark) to black (if navbar-light), so that the text colour on your navbar doesn't conflict with the navbar colours
you can do this:
.navbar {background-color: #5f788a;}
and add the class "navbar-dark" to your nav element.
This is assuming you're using the latest version of bootstrap, 4.3
Bootstrap 4.0.0 Demo below:
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: #444444;
}
.bg-steel {
background-color: #5f788a;
}
.site-header .navbar-nav .nav-link {
color: #5f788a;
}
.site-header .navbar-nav .nav-link:hover {
color: #ffffff;
}
.site-header .navbar-nav .nav-link.active {
font-weight: 500;
}
.content-section {
background: #ffffff;
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
margin-bottom: 20px;
}
.article-title {
color: #444444;
}
a.article-title:hover {
color: #428bca;
text-decoration: none;
}
.article-content {
white-space: pre-line;
}
.article-img {
height: 65px;
width: 65px;
margin-right: 16px;
}
.article-metadata {
padding-bottom: 1px;
margin-bottom: 4px;
border-bottom: 1px solid #e3e3e3
}
.article-metadata a:hover {
color: #333;
text-decoration: none;
}
#parent {
list-style: none;
width: 100%;
height: 90px;
margin: 0;
padding: 0;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
}
.article-svg {
width: 25px;
height: 25px;
vertical-align: middle;
}
.account-img {
height: 125px;
width: 125px;
margin-right: 20px;
margin-bottom: 16px;
}
.account-heading {
font-size: 2.5rem;
}
#import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css");
<!DOCTYPE html>
<!-- saved from url=(0044)https://stack.fleeksite.com/bootstrap-navbar -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>TurboTobias</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<header class="site-header">
<nav class="navbar navbar-default navbar-expand-md navbar-dark fixed-top" style="background-color: rebeccapurple;">
<div class="container">
<a class="navbar-brand mr-4" href="https://stack.fleeksite.com/">Bench of Thoughts (v0.01)</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="https://stack.fleeksite.com/about">About</a>
</div>
<!-- Navbar Right Side -->
<div class="navbar-nav">
<a class="nav-item nav-link" href="https://stack.fleeksite.com/login"><span class="glyphicon glyphicon-log-in"></span> Login</a>
<a class="nav-item nav-link" href="https://stack.fleeksite.com/register"><span class="glyphicon glyphicon-user"></span> Register</a>
</div>
</div>
</div>
</nav>
</header>
</body>
</html>
you can just add:-
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
Instead of what you wrote earlier