Flex div always take remaining height - html

I'm making a web page but I'm having a hard time making it responsive and fit my desires.
I'm making a login page with an alert box, the alert will only appear if the user types a wrong password or email.
What I want to happen is for the main div (flex-3) content to be centered on the page and when the alert (flex-2) appears for the page to not have a scroll wheel, so flex-3 kinda has to calculate the remaining height of the page and be centered, and obviously all of this has to work no matter the device resolution.
I tried doing this with flex div but the closest I got made so the alert increased the total height of the page, so it would have a scroll wheel with no content at the bottom.
html,
body {
color: #fff;
height: 100%;
min-height: 100%;
}
.flex-1 {
flex: 1;
background-color: red;
}
.flex-2 {
display: flex;
background-color: green;
}
.flex-3 {
display: flex;
background-color: black;
}
<html>
<head>
<!-- import bootstrap css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<!-- import jquery and bootstrap -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
</head>
<body class="d-flex flex-column">
<header>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">
<img src="" class="d-inline-block align-top" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id='navbarNav'>
<ul class="navbar-nav navbar-right">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="flex-1">
<div class="flex-2 d-flex alert-test">
<h1>TEST</h1>
</div>
<div class="flex-3 d-flex justify-content-center align-items-center">
<h1>TEST</h1>
</div>
</main>
</body>
</html>

This is how I made your solution working.
Added display: flex; flex-direction: column; to flex-1 to make the 2nd point working.
Added flex-grow: 1 to flex-3 class to make the dive stretch in remaining area.
Only by adding display: flex to the parent class flex-1, the flex grow property of child class, flex-3 works.
Hope this is the solution that you are looking for.
html,
body {
color: #fff;
height: 100%;
min-height: 100%;
}
.flex-1 {
display: flex;
flex-direction: column;
flex: 1;
background-color: red;
}
.flex-2 {
display: flex;
background-color: green;
}
.flex-3 {
display: flex;
flex-grow: 1;
overflow: auto;
background-color: black;
}
<!-- import bootstrap css -->
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
/>
<!-- import jquery and bootstrap -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<body class="d-flex flex-column">
<header>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">
<img src="" class="d-inline-block align-top" alt="" />
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div
class="collapse navbar-collapse justify-content-end"
id="navbarNav"
>
<ul class="navbar-nav navbar-right">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="flex-1">
<div class="flex-2 d-flex alert-test">
<h1>flex-2 TEST</h1>
</div>
<div class="flex-3 d-flex justify-content-center align-items-center">
<h1>flex-3 Test</h1>
</div>
</main>
</body>

Related

Div not centered and footer moves up

I would like the div (home) to be in the middle of the page. The problem with me is that when I shrink the browser window at the bottom, the footer moves up with it and then eventually disappears underneath. And should I reduce the page in the browser, so zoom out, then you can see that the logo and the text are not in the middle.
I can't get the footer to stay at the bottom and the logo and text to be in the middle of the page.
I use Bootstrap 5
CODE: https://jsfiddle.net/esznkh4r/3/
VIDEO: https://i.imgur.com/XRAX2bq.mp4
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
min-height: 100vh;
position: relative;
display: flex;
flex-direction: column;
}
.home {
padding-top: 150px;
}
.logo {
height: 200px;
width: 200px;
border-radius: 100%;
}
.text {
text-transform: uppercase;
text-align: center;
}
footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height:50px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="wrapper">
<div class="home">
<div class="container">
<img class="logo d-block mx-auto mb-4" src="https://duckduckgo.com/assets/common/dax-logo.svg" alt="LOGO">
<div class="text">
<h1>TEST</h1>
<h6>BLABLABLABLABLA</h6>
</div>
</div>
</div>
</div>
<footer>
<div class="container d-flex flex-wrap justify-content-between align-items-center py-3">
<div class="col-md-4 d-flex align-items-center">
<span>TEST</span>
</div>
<ul class="nav col-md-4 justify-content-end d-flex">
<a class="mb-0 justify-content-end" target="_blank">TEST</a>
</ul>
</div>
</footer>
Try like this.
Set flex property into .wrapper.
Code
You can try this, remove .home class style, and add
.wrapper {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
Just added some property in .home class
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
min-height: 100vh;
position: relative;
display: flex;
flex-direction: column;
}
.home {
padding: 150px 0;
flex: 1;
align-items: center;
justify-content: center;
}
.logo {
height: 200px;
width: 200px;
border-radius: 100%;
}
.text {
text-transform: uppercase;
text-align: center;
}
footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height:50px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="wrapper">
<div class="home">
<div class="container">
<img class="logo d-block mx-auto mb-4" src="https://duckduckgo.com/assets/common/dax-logo.svg" alt="LOGO">
<div class="text">
<h1>TEST</h1>
<h6>BLABLABLABLABLA</h6>
</div>
</div>
</div>
</div>
<footer>
<div class="container d-flex flex-wrap justify-content-between align-items-center py-3">
<div class="col-md-4 d-flex align-items-center">
<span>TEST</span>
</div>
<ul class="nav col-md-4 justify-content-end d-flex">
<a class="mb-0 justify-content-end" target="_blank">TEST</a>
</ul>
</div>
</footer>

Align navigation bootstrap center

I want to center align the navigation links from Bootstrap but since I'm not using the list structure, all solutions don't work.
<section id="menuNavigation">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg">
<button class="navbar-toggler" type="´button" data-toggle="collapse" data-target="#navbarHeader">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarHeader">
<ul class="navbar-nav">
Uniongs
Sobre
Seja Assinante
Blog
Publicidade
</ul>
</div>
</nav>
</div>
</section>
I tried everything: text-center, text-align: center, justify-content-center and nothing works.
Your HTML is invalid. ul can only have li as children. Try using a div instead.
Then use the flexbox helper classes available to you in BS4.
<div class="navbar-nav d-flex justify-content-center">
Then we just make the menu full width by adding flex:1. The reason the list items wouldn't center is because the menu was not full width and itself, left aligned.
View in Full Page mode.
.navbar-nav {
flex: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<section id="menuNavigation">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg">
<button class="navbar-toggler" type="´button" data-toggle="collapse" data-target="#navbarHeader">
<span class="navbar-toggler-icon">Toggle</span>
</button>
<div class="collapse navbar-collapse " id="navbarHeader">
<div class="navbar-nav d-flex justify-content-center">
Uniongs
Sobre
Seja Assinante
Blog
Publicidade
</div>
</div>
</nav>
</div>
</section>
Just CSS code added. hope this help you.
.navbar-nav {
text-align: center;
width: 100%;
float: left;
display: inline-block;
}
.nav-link {
float: none;
display: inline-block;
padding:0 10px;
}
<section id="menuNavigation">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg">
<button class="navbar-toggler" type="´button" data-toggle="collapse" data-target="#navbarHeader">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarHeader">
<ul class="navbar-nav">
Uniongs
Sobre
Seja Assinante
Blog
Publicidade
</ul>
</div>
</nav>
</div>
</section>

place html after a full screen height responsive div using Bootstrap 4

Basically I have 3 main components: 1 navbar, 1 content div separated in sections and 1 footer.
I've finally made my design responsive with for the first two components but not for the footer.
my content container (parent) have the class h-100 that sets the height to 100% child also have a 100% value only problem is that when I use inspector I see my parent container recognized as having a the size of the screen and because of that the footer is placed after the first section (there's 3 or more sections that should be 3 or more times the height of the screen minus the navbar)
here is a reproduction of the resulting html (I'm normally using Angular)
#media (max-width: 979px) {
.section {
padding-top: 0px;
}
}
.section{
display: flex;
min-height: 100%;
height: 100%;
border: 1px solid black;
padding-top: 60px;
}
.inner-section{
padding:5%;
border: 1px solid black;
}
html, body {height: 100%;}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-md navbar-light bg-success fixed-top">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarAHS" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarAHS">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" >testleft</a>
</li>
</ul>
<ul class="navbar-nav mx-auto order-0">
<li class="nav-item">
<a class="nav-link">testmiddle</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#hello">testRight</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid h-100">
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10 h-100">
hello
</div>
</div>
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10 h-100">
hi
</div>
</div>
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10 h-100">
hey
</div>
</div>
</div>
<div class="row">
Footer is not placed correctly
</div>
Your issue is that your are specifying height 100% for the container, but 100% of what? In your case the body tag, but the body gets it's height from the size of your content(which on full screen is about 1000px for the first content box), then you also specify 100% height for each of your content boxes. Again 100% of what? The container, which is 1000px is this example. So the footer jumps up after what it thinks the size of page, but then each of the additional content boxes also get that same height, which leads to your weird situation.
In short if you need to keep the 100% height on the container, try adding overflow: auto to the container. Otherwise you could remove the 100% height rule from the container.
here is my solution.
please tell me if it is not a best practice.
every row is wrapped into div with h-100 as class and it works
I also removed container-fluid
HTML
#media (max-width: 979px) {
.section {
padding-top: 48px;
}
}
.section{
display: flex;
min-height: 100%;
height: 100%;
border: 1px solid black;
padding-top: 48px;
}
.inner-section{
padding:5%;
border: 1px solid black;
}
html, body {height: 100%;}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-md navbar-light bg-success fixed-top">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarAHS" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarAHS">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" >testleft</a>
</li>
</ul>
<ul class="navbar-nav mx-auto order-0">
<li class="nav-item">
<a class="nav-link">testmiddle</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#hello">testRight</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="h-100">
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10">
hello
</div>
</div>
</div>
<div class="h-100">
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10">
hey
</div>
</div>
</div>
<div class="h-100">
<div class="row section justify-content-md-center">
<div class="inner-section col-md-10">
ola
</div>
</div>
</div>
<div class="row">
Footer is placed correctly.
</div>

How to center a bootstrap 4 row vertically and horizontally when there are some rows before

Let's assume we have a main menu and three rows afterwards. The first row should be at the top, the third at the bottom. The second row has to be centered vertically and horizontally.
When you scroll down you should be able to hide the main menu but everything else should fit in the page.
I know this, I know about justify-content-center and I played a bit around with this. But I can't put it together.
The second row is centered vertically but it stretches the height and it's not correctly centered horizontally anymore.
Here is what I tried:
.vertical-center {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
}
html, body, {
height: 100%;
}
.header {
float: left;
width: 100%;
}
.full {
height: 100%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</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>
<div id="nav">
<div class="container-fluid navbar-main">
<nav class="navbar navbar-expand-md no-padding navbar-main">
<div class="container">
<a class="navbar-brand" href="#">Main menu</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Menü aufklappen">
<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" href="/" role="button">Start</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="container">
<div class="row">
<div class="col header">
<span id="score">first row </span>
</div>
</div>
<div class="row justify-content-center vertical-center" style="height:100%">
<!-- div to center -->
<div class="col-auto">
<span id="operand1">text</span>
</div>
<div class="col-auto">
<span id="operator">text</span>
</div>
<div class="col-auto">
<span id="operand2">text</span>
</div>
<div class="col-4">
<span id="operand2">text</span>
</div>
</div>
</div>
</body>
</html>
You should be using the "col-auto" for all the the divs in the 2nd row.
Have a look at this
.vertical-center {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
}
html, body, {
height: 100%;
}
.header {
float: left;
width: 100%;
}
.full {
height: 100%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</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>
<div id="nav">
<div class="container-fluid navbar-main">
<nav class="navbar navbar-expand-md no-padding navbar-main">
<div class="container">
<a class="navbar-brand" href="#">Main menu</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Menü aufklappen">
<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" href="/" role="button">Start</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="container">
<div class="row">
<div class="col header">
<span id="score">first row </span>
</div>
</div>
<div class="row justify-content-center vertical-center">
<!-- div to center -->
<div class="col-auto">
<span id="operand1">text</span>
</div>
<div class="col-auto">
<span id="operator">text</span>
</div>
<div class="col-auto">
<span id="operand2">text</span>
</div>
<div class="col-auto">
<span id="operand2">text</span>
</div>
</div>
</div>
</body>
</html>
Wrap everything inside that row with a div that has a class called centered. For example, add position relative to the parent row and add css class:
.centered{position:absolute; top:50%; left:50%;}

Padding-top won't work

I am trying to put my "Sanchez Designs......Ms Sanchez....and "Web Developer, Artist and Higher Education" buttons midway into the page, right about at the peak of the mountain. I have researched and tried but am unable to move it. I thought padding-top would do the trick but nope. Any suggestions?
Also, I'm learning web development so please be gentle. Thanks!
body {
background-image: url('images/background3.jpeg');
width: 100%;
height: 100%;
background-position: top center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
font-family: 'Lato', sans-serif;
color: white;
}
#media only screen and (max-width: 767px) {
body {
background-image: url('images/background3.jpeg');
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="http://path/to/font-awesome/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="Sanchez_Bootstrap_index.css">
</style>
<title>Sanchez</title>
</head>
<body>
<!--NAVBAR-->
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="">Andrea Designs</a>
<!--Toggle Button-->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span></button>
<!--Navbar links-->
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<li class="nav-item">
<a class="nav-link" href="Sanchez_bootstrap_about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Sanchez_bootstrap_artist.html">Artist</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Sanchez_bootstrap_highered.html">Higher Education</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<div id="content">
<h1> Sanchez Designs</h1>
<h5> Ms. Sanchez is an aspiring Web Developer</h5>
<hr>
<ul class="list-inline intro-social-buttons">
<li class="list-inline-item">
<a href="Sanchez_Bootstrap_about.html" class="btn btn-dark btn-lg">
<span class="network-name">Web Developer</span></a>
</li>
<li class="list-inline-item">
<a href="Sanchez_Bootstrap_artist.html" class="btn btn-dark btn-lg">
<span class="network-name">Artist</span></a>
</li>
<li class="list-inline-item">
<a href="Sanchez_Bootstrap_highered.html" class="btn btn-dark btn-lg">
<span class="network-name">Higher Education</span></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<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://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>
IF you want padding top try
padding-top : 20px!important
if you want div test in center why you try padding top or bottom . you can use a extra div and give style display: flex; align-items: center;
.banner {
height: 80vh;
align-items: center;
vertical-align: middle;
display: flex;
}
like : https://www.w3schools.com/code/tryit.asp?filename=FNBF6UP5MV4S
There are a lot of way to add padding or margin here.
You can add padding-top to your .col-lg-12 if your content and navbar have 2 different container by simply add another class and add padding to it.
HTML
<div class="col-lg-12 text-center padding-content">
<div id="content">
...
CSS
.padding-content {
padding-top: 30px;
}
Demo: https://www.bootply.com/jpU6nmgw8z
Or you can add margin to your navbar
CSS
.navbar {
margin-bottom: 30px;
}
Demo: https://www.bootply.com/k6vGFbX5XC
Did you try adding margin-top to say, the "content" div?
#content {
margin-top: 5%;
}
Codepen link: https://codepen.io/anon/pen/zpRQVL