Bootstrap 4: Full Width Inline Button - html

The title might be misleading, but I didn't know how else to name it.
In any case, I need to have an div/image inlined with a text, and a button beneath that text. The issue is, I can't really make the button take the full width without adding any padding, no matter what I try.
To make my explanation clearer, here's an image of what I'm trying to make:
And I'm trying to use Bootstrap 4 utilities only.
This is my code so far:
.col-md-3 {
background-color: #ededed;
}
.img {
width: 188px;
height: 88px;
background-color: #292a2c;
}
.btn {
background-color: #292a2c;
color: #ededed;
}
<div class="col-md-3 d-flex p-0">
<div class="img"></div>
<div>
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>
How can I make this work? Also, the div with a class .img is a placeholder in a way, and needs to stay like that.
Thank you!

You can achieve this by using bootstrap media object with no additional css. Please see code snippet below
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="media">
<img src="https://via.placeholder.com/188x88" class="mr-3" alt="">
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
<button class="btn btn-primary btn-block">Button</button>
</div>
</div>
</div>
</div>
</div>

You can try something like this, then style it accordingly:
<div class="container-fluid">
<div class="row">
<div class="col-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ79Qe630Fli9-SIDz188GQURmrRfhh6AksMKexPP5JvsE7AJ6t01mf5A">
</div>
<div class="col-8">
<div class="row">
<p>text</p>
</div>
<div class="row">
<button>button</button>
</div>
</div>
</div>
</div>

Here is the code for getting as shown in the image
'<div class="col-md-12"><div class="row"><div class="col-md-3"><div class="row"><div class="img"></div></div></div>
<div class="col-md-6"><div class="row">
<h6 class="m-auto">Text goes here</h6><button class="btn rounded-0 btn-block">Button</button></div></div></div>
For style use the style in your question

You could do something like this.
Note that Bootstrap by default does not have a black background class so you would have to create one.
.bg-black {
background-color: #000 !important;
border: 2px solid #000 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid"> <!-- Make it full width -->
<div class="row d-flex"> <!-- display flex -->
<div class="col-4 align-self-stretch"> <!-- stretch the column -->
<img class="w-100" src="http://placehold.it/200x200" />
</div>
<div class="col-8 align-self-stretch"> <!-- stretch the column -->
<p>Some Text Here.<br/> Can be long or short</p>
<p>Yet another paragraph</p>
<p>And one more paragraph</p>
<button class="btn btn-primary bg-black btn-block rounded-0">Btn Txt</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>

.col-md-3 {
background-color: #ededed;
width:100% !important;
}
.col-md-3> div{
display:inline-block;
float:left;
width: 60%;
height:100%;
}
.img {
width: 15% !important;;
height: 88px !important;
background-color: #292a2c;
display:inline-block;
}
.btn {
width: 60%;
background-color: #292a2c;
color: #ededed;
height:50%;
display:inline-block;
}
<div class="col-md-3 d-flex p-0">
<div class="img"></div>
<div>
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>

Everything looks good just make sure that you have bootstrap.css file in right place and make sure that its working.
I made some changes to your code, its a bit hard coded but u must take care to overwrite bootstrap classes and don't change them directly.
.box {
background-color: #ededed;
}
.img {
width: 188px;
height: 88px;
background-color: #292a2c;
float: left;
margin-right: 5px;
}
.text {
float: left;
}
.btn {
background-color: #292a2c;
color: #ededed;
margin-top: 33px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-6 d-flex p-0">
<div class="box">
<div class="img"></div>
<div class="text">
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>
</div>

Related

How can I get my logo sticky in a div while using bootstrap?

I'm trying to get my logo stick to the top of the page but I can't manage to do that.
I've tried with:
#logo {
position: sticky;
top:0
}
I also check if there's an overflow property but I've found nothing, I'm also using bootstrap framework version 5.
This is the part where I've put logo:
<div class="container" id="header">
<div class="row">
<div class="col-4 col-md-3 align-items-start d-flex">
<img src="../media/logos/mb-logo.png" id="logo" class="img-fluid" alt="logo">
</div>
<div class="col-7 col-md-8 align-items-end justify-content-end d-flex" id="menu_mobile">
<div class="row">
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">about me</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">competencies</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">portfolio</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">contact</span>
</div>
</div>
</div>
<div class="col justify-content-end align-items-center d-flex" id="menu_desk">
<span class="menu_item_desk">about me</span>
<span class="menu_item_desk">competencies</span>
<span class="menu_item_desk">portfolio</span>
<span class="menu_item_desk">contact</span>
</div>
</div>
</div>
Can someone help me?
edit: after trying the solution posted by #Fork:
<div class="container" id="header">
<div class="row">
<div class="col-4 col-md-3 align-items-start d-flex " >
<img src="../media/logos/mb-logo.png" id="logo" class="img-fluid position-fixed top-0" alt="logo">
</div>
The logo stay in position while I scroll down but other element changed of disposition. I managed to fix them adding some paddings and margin
edit 2: Here's the snippet and thanks to Fork now it works fine, another thing I would like to accomplish is that when the page is scrolled, the image goes up above the page for a tiny bit. I found this fiddle but is not exactly what i mean https://jsfiddle.net/z2r40y8c/. The image needs to go up and block at a specified amount of pixels.
html {
scroll-behavior: smooth;
}
body {
width: 100%;
height: 2000px
}
a{
text-decoration: none;
}
.container {
max-width: 100%;
padding: 0%;
margin: 0%;
}
body{
background-color: #161616;
}
#logo {
margin-left: 25px !important;
position: fixed;
top:0
}
.menu_mobile{
padding-top: 5%;
}
.menu_item {
font-family: 'sublimaextrabold';
font-size: 18px;
color: rgba(112,112,112,1);
padding-bottom: 5%;
cursor: pointer;
}
#media only screen and (min-width: 810px) {
#menu_mobile {
display: none !important;
}
}
#media only screen and (max-width: 810px) {
#menu_desk {
display: none !important;
}
}
.menu_item_desk {
font-family: 'sublimaextrabold';
color: rgba(112,112,112,1);
padding-left: 5%;
font-size: 30px;
cursor: pointer;
padding-top: 5%;
}
#media only screen and (max-width: 1197px) {
.menu_item_desk {
font-size: 24px;
}
}
#media only screen and (max-width: 993px) {
.menu_item_desk {
font-size: 20px;
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MB</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="../html/style.css">
</head>
<body ondragstart="return false;" ondrop="return false;">
<div class="container" id="header">
<div class="row">
<div class="col-sm-12">
<div class="container">
<div class="col-sm-3 align-items-start d-flex">
<img src="https://www.startpage.com/av/proxy-image?piurl=https%3A%2F%2Fdictionary.cambridge.org%2Ffr%2Fimages%2Fthumb%2Foblong_noun_002_25303.jpg%3Fversion%3D5.0.245&sp=1657096049T030f5c6f84a41f399845576d2d63d9849144e614f9e0077172506ae40946828e" id="logo" class="img-fluid position-fixed top-0" alt="logo">
</div>
<div class="col-sm-11 d-flex justify-content-end align-items-center " id="menu_desk">
<span class="menu_item_desk">section 1</span>
<span class="menu_item_desk">section 2</span>
<span class="menu_item_desk">section 3</span>
<span class="menu_item_desk">section 4</span>
</div>
<div class="col-11 align-items-end pt-3 justify-content-end d-flex" id="menu_mobile">
<div class="row">
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">section 1</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">section 2</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">section 3</span>
</div>
<div class="col-12 justify-content-end d-flex">
<span class="menu_item">section 4</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Not sure why you just want the position: sticky; just on the logo rather than the whole navigation bar, but if you want to go that route, I would suggest using position: fixed; instead. Additionally, apply it to the div that's surrounding your image. Like so:
<div class="col-4 col-md-3 align-items-start d-flex position-fixed top-0">
<img src="../media/logos/mb-logo.png" id="logo" class="img-fluid" alt="logo">
</div>
Hope this helps :)
As far as I know the problem is, that for some constructions, like a bootstrap carousel, if you want to display it on a fullscreen, bootstrap requires the height of html to be set to 100%.
For position: sticky it is required to have no height set.
You could try making the nav sticky with JS:
const nav = document.querySelector('#nav');
let navTop = nav.offsetTop;
function fixedNav() {
if (window.scrollY >= navTop) {
nav.classList.add('fixed');
} else {
nav.classList.remove('fixed');
}
}
window.addEventListener('scroll', fixedNav);
and the CSS for the activated navbar:
#nav.fixed {
position: fixed;
box-shadow: 5px 5px 19px 0px rgba(0, 0, 0, 0.5);
}
#nav.fixed ul li img {
height: 36px;
}
#nav.fixed ul li a {
font-size: 14px;
}

unable to manage bootstrap 4 div elements to the responsive design

I'm working with bootstrap 4 and following codes,
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.css">
<div class="card-header rounded-0 border border-dark">
<div class="row">
<div class="col-12 col-md-4 ">
<img src="{{asset('images/usa.jpg')}}" alt="..." class="rounded-circle">
</div>
<div class="col-12 col-md-8 ">
<p>This is not a game fgfhg dfghdh dhdhdf dfgdhfhg dfdfhfh dfhdfhdf dfhdfh</p>
</div>
</div>
</div>
I need display above two div elements in the same row on large screen and need separate two rows (image is above and paragraph is under the image) when it is displaying mobile device. I use following col-12 col-sm-8 col-md-6 col-lg-4 col-xl-3 item codes in side to the div but not success.
how could I manage this problem?
View in Full Page , You will get it
body {
padding-top: 40px;
}
.col-sm-6 {
background: #ccc;
}
.other {
background: #a4a4a4;
}
.p {
text-align: center;
padding-top: 120px;
}
.p a {
text-decoration: underline;
color: blue;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-6">
<h1>Bootstrap Grid Demo</h1>
</div>
<div class="col-sm-6 other">
<h1>2 Columns</h1>
</div>
</div>
</div>
<p class="p">Demo by Jabir Sayed. See article.</p>

Image spanning to the next div when window size is decreased

So, I have to create this Page where in you get text alongside image displayed as seen in here
But , on minimising the window size the image gets overlapped as seen here
<div class="header1">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="pull-right img1">
</div>
</div>
and Here is the css
.hedtext {
padding-top:10px;
margin-bottom: -19px;
line-height: 2pt;
font-size: 13px;
font-weight: 750;
float: left;
}
.header1 {
border: 1px solid black;
height: 150px;
}
.img1 {
width: auto;
height: 130px;
padding :10px;
}
Also, using bootstrap 3 . All i want is that the image goes side by side the text on minimising the window size .
First you have forgot to add the .row class div which bootstrap requires to wrap around the columns to work correctly.
I removed .pull-right and instead just added text-right to the column. You can also use floats though or whatever to set the image to the right side however you wish.
<div class="header1 row">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4 text-right">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
class="img1">
</div>
</div>
You have to wrap col in row
Remove the .hedtext - float (bootstrap worry about float)
Remove .header1 height: 130px; (It the reason image out of border)
See working code
.hedtext {
line-height: 2pt;
font-size: 13px;
font-weight: 750;
}
.row {
border: 1px solid black;
}
.img1 {
width: auto;
height: 130px;
padding: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/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.4.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
<h4 class="hedtext">Address</h4>
<h4 class="hedtext">Contact Number</h4>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="img1">
</div>
</div>
</div>
you have to add responsive class in div like col-xs-* for responsive
do this for your solution
<div clss="row">
<div class="header1">
<div class="col-md-8 col-xs-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4 col-xs-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
class="pull-right img1">
</div>
</div>
</div>

How to draw equal horizontal lines between one button to another in angular 4

Here I am trying to draw a horizontal line between the buttons. I have tried in many ways but I can't get it. I think I need to do some magics in CSS but I am new to HTML and CSS That's why I can't find the way to make it work.
I want:
I got this:
.divided {
display: flex;
align-items: center;
}
.divider {
flex-grow: 1;
border-bottom: 1px solid black;
margin: 5px
}
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Can anyone help me to solve this ?
Update:
Use pseudo :after to <div class="col-sm-3 divder">
Instead using <span class="divider"></span> (-- remove it)
.divder:after{
content: '';
width: 71px;
height: 2px;
top: 15px;
background: black;
position: absolute;
right: -12px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3 divder">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I think you're trying to do the same as you would do when using a stepper
https://material.angular.io/components/stepper/overview
Using import {MatStepperModule} from '#angular/material/stepper';
and the correct elements will do the trick
You can use :after psuedo class
.divider:after {
height:1px;
width:40px;
content:'';
background: red;
position:absolute;
right:0px;
top:15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="col-sm-12" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:0px">Login</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:0px">Address</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:0px">Mycart</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:0px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Following code adds equally sized lines between menu items as long there is enough space.
/* all direct children of menu and item are laid out in a single row as long as there is enough space */
.menu,
.item {
display: flex;
flex-flow: row wrap;
}
/* all menu items can grow except the last one */
.item:not(:last-child) {
flex-grow: 1;
}
/* a horizontal line is appended to all items if space is available (except the last item) */
.item:not(:last-child):after {
content: '';
border-bottom: 1px solid #000;
height: 50%; /* centers line vertically */
flex-grow: 1;
margin-right: 10px;
}
/* not relevant for menu (typography and resets) */
button,
span {
font-family: Times;
font-size: 16px;
padding: 0;
border: 0;
margin-right: 10px;
}
/* not relevant for menu (rounded buttons) */
button {
background-color: #ddd;
border-radius: 50%;
height: 20px;
width: 20px;
}
<div class="menu">
<div class="item">
<button>1</button>
<span>Login</span>
</div>
<div class="item">
<button>2</button>
<span>Address</span>
</div>
<div class="item">
<button>3</button>
<span>Mycart</span>
</div>
<div class="item">
<button>4</button>
<span>Payment</span>
</div>
</div>
A

Page content overlapping navbar

I am having some trouble with some of my bootstrap cards overlapping my navbar. I made sure that none of my positions were absolute and that the z indexes were handled properly, but I still get the same issue. doing padding-top on the body did not give me the result I wanted either. Here are some before and after pictures.
#top {
top: 0;
position: fixed;
z-index: 1;
}
.topbar {
height: 90px;
background-color: #24414e;
border-left: 2px solid #24414e;
border-right: 2px solid #24414e;
border-top: 2px solid #24414e;
border-bottom: 2px solid #24414e;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
animation-name: greeting;
animation-duration: 8s;
animation-delay: 1s;
}
#keyframes greeting {
0% {
background: url('https://cdn.dribbble.com/users/751466/screenshots/3360272/hello-3.gif');
background-size: 100% 100%;
}
60% {
opacity: 1;
}
}
/*
.topbar:hover{
background:url('https://cdn.dribbble.com/users/751466/screenshots/3360272/hello-3.gif');
background-size: 100% 100%;
}
*/
.logo {
transform: translateY(50%);
font-family: "Dancing Script";
color: #ffffff;
}
.holder {
width: 5%;
height: 80%;
margin-right: 30px;
margin-top: 10px;
}
.out {
margin-top: 46px;
color: #ffffff;
margin-right: 0;
}
.out:hover {
text-decoration: underline;
}
.menu {
height: 15%;
margin-top: 0px;
background-color: #f7ce3e;
}
/*
.iconbar{
margin-top: 20px;
margin-right: 20px;
margin-left:20px;
height =
text-align: center;
border-left: 2px solid #24414e;
border-right: 2px solid #24414e;
border-top: 2px solid #24414e;
border-bottom: 2px solid #24414e;
}
*/
.icon {
margin-top: 10px;
color: #24414e;
animation-name: iconSlide;
animation-duration: 1s;
}
.txt {
font-size: 15px;
visibility: hidden;
margin-top: 0px;
color: #24414e;
}
#keyframes iconSlide {
0% {
transform: translateX(600%);
}
100% {
transform: translateX(0);
}
}
.icon-1:hover~.txt-1 {
visibility: visible;
}
.icon-2:hover~.txt-2 {
visibility: visible;
}
.icon-3:hover~.txt-3 {
visibility: visible;
}
.icon-4:hover~.txt-4 {
visibility: visible;
}
.icon-5:hover~.txt-5 {
visibility: visible;
}
.icon-6:hover~.txt-6 {
visibility: visible;
}
.icon:hover {
color: #ffffff;
}
.rest {
height: 100%;
}
.contacts {
position: relative;
z-index: -1;
}
<!DOCTYPE html>
<html lang="en">
<!---This is for importing bootstrap and the CSS File--->
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="templatestyle.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Dancing Script' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!---Nav Bar and Header--->
<section id="top">
<!---Header--->
<div class="container-fluid topbar">
<h1 class="float-left logo">Example</h1>
<h5 class="float-right out">log out</h5>
<img src="blank-person-male.png" alt="profilepic" class="rounded-circle float-right holder"></img>
</div>
<!---Nav Bar--->
<div class="container-fluid menu" id="openMenu">
<div class="row">
<div class="col-2 text-center">
<i class="fa fa-tachometer fa-2x icon icon-1" aria-hidden="true"></i>
<h5 class="txt txt-1">Dashboard</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-user fa-2x icon icon-2" aria-hidden="true"></i>
<h5 class="txt txt-2">Profile</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-certificate fa-2x icon icon-3" aria-hidden="true"></i>
<h5 class="txt txt-3">Certificates</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-paper-plane fa-2x icon icon-4" aria-hidden="true"></i>
<h5 class="txt txt-4">Send/Apply</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-cog fa-2x icon icon-5" aria-hidden="true"></i>
<h5 class="txt txt-5">Settings</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-envelope fa-2x icon icon-6" aria-hidden="true"></i>
<h5 class="txt txt-6">Messages</h5>
</div>
</div>
</div>
</section>
<section class="rest container-fluid">
<h2 class="text-center"><u>Dashboard</u></h2>
<!---Contacts--->
<h4>Online contacts:</h4>
<div class="row contacts">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 1</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 2</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 3</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 4</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 5</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 6</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 7</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
This is a simple fix, just set your Header z-index: 2; and your cards z-index: 1;.
I didn't really go over your code but setting the header an higher z-index as the content for sure will fix it.
The answer is you have given position:fixed to the header(.top) to fix it at the top with top:0, so you must need to give margin-top to the section next to it containing classes class="rest container-fluid" otherwise it will overlap as it seems with absolute positioned element.
Setting margin:top:159px fix the issue.
Please note that 159px is top header's height here. Happy coding :)
Use the fixed-top class instead of the top CSS code. And add 160px padding-top for the body.
/*
The headers height is 159.5px
*/
body {
padding-top: 160px;
}
fixed-top removes the element that you use it for, from the normal flow of the content, and, hence, the element will overlay the other content
To fix the issue, you need to push down the main content equal or larger than the height of the fixed-top element. You can do so by setting the padding-top of the body equal or larger than the fixed-top element's height. For example, if the fixed-top element's height is 72px, padding-top of body should be, at least, 72px. If you wish, you can use relative units: padding-top: 4.5rem; instead of padding-top: 72px;.
body {
padding-top: 72px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="fixed-top bg-light">
<div>
<noscript>
<h1 style="color:#FF0000;">
This reportFile will not be navigable without Javascript, please enabled Javascript
</h1>
</noscript>
<img srcset="style/songkongheader.png 400w,style/songkongheader-medium.png 200w,style/songkongheader-small.png 100w," sizes="(max-width:800px) 200px,(max-width:600px) 100px,400px" class="mb-2">
</div>
<header>
<h2 class="subheading" title="Start Fixing Songs">
<a class="mx-2">
Fix Songs
</a>
</h2>
</header>
</div>
<main class="container-fluid bg-primary bd-">
<div class="row">
<div class="col py-5">Hello</div>
</div>
</main>
This is what both bootstrap-3 and bootstrap-4 has done. I recommend you to inspect it yourself.
You may find these two link useful.
w3schools - How to - fixed menu
teamtreehouse - div hiddne below fixed position navbar
A codepen of your work