Fixed bottom not working with parent having overflow - html
I'm wanting to have a sticky footer nav type of thing on the bottom of my first col-6 (within, not outside) the div. Problem is, it has overflow which seems to be preventing me from getting it to work. Closest I got to was it starting in the correct position, then it scrolled due to the overflow. I'm scratching my head a bit here.
PS- Sorry there's a lot of code, I added a lot of placeholders to force the overflow so it's more authentic.
.b-wrapper {
border-radius: 4px;
width: 90vw;
height: 90vh;
max-width: 1024px;
max-height: 768px;
}
.booking-item {
padding: 30px 15px 30px 15px;
cursor: pointer;
border-bottom: 2px solid #f5f5f5;
min-height: 30px;
}
.tts {
max-height: 650px;
overflow-y: auto;
}
.book_apt {
position: fixed;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
/* Vertically center the text there */
background-color: #f5f5f5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container" style="height:100vh;">
<div class="row justify-content-center h-100">
<div class="col-12 my-auto mx-auto">
<div class="card">
<div class="card-body p-0">
<div class="row">
<div class="col-6 pr-0 tts">
<div class="book_apt">
<a class="btn btn-primary" href="#">Book Service</a>
</div>
<!-- Added a lot to force the overflow -->
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
Massage Therapy (60 minutes)
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-6">
</div>
</div>
</div>
</div>
</div>
</div>
Change position: fixed; to position: sticky; and move book_apt to the bottom of your col-6.
This should do the trick.
.b-wrapper {
border-radius: 4px;
width: 90vw;
height: 90vh;
max-width: 1024px;
max-height: 768px;
}
.booking-item {
padding: 30px 15px 30px 15px;
cursor: pointer;
border-bottom: 2px solid #f5f5f5;
min-height: 30px;
}
.tts {
max-height: 650px;
overflow-y: auto;
}
.book_apt {
position: sticky;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
/* Vertically center the text there */
background-color: #f5f5f5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container" style="height:100vh;">
<div class="row justify-content-center h-100">
<div class="col-12 my-auto mx-auto">
<div class="card">
<div class="card-body p-0">
<div class="row">
<div class="col-6 pr-0 tts">
<!-- Added a lot to force the overflow -->
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="booking-item" id="booking">
<div class="row">
<div class="col-2">
<div class="form-check my-auto">
<input class="form-check-input" type="checkbox" value="" id="test-check">
</div>
</div>
<div class="col-6 my-auto">
<h6 class="mb-0 pb-0">Swedish Massage</h6>
<small><i>30min</i></small>
</div>
<div class="col-4 my-auto text-right">
GBP £38
</div>
</div>
</div>
<div class="book_apt">
<a class="btn btn-primary" href="#">Book Service</a>
</div>
</div>
</div>
</div>
<div class="col-6">
</div>
</div>
</div>
</div>
</div>
.book_apt {
background-color: #ddd;
position: fixed;
padding: 2em;
left: 50%;
bottom: 8%;
transform: translateX(-50%);
width: 58%;
z-index: 1000;
}
Related
Bootstrap Nested Column Checkbox Padding
I have two nested columns in one row, one set of columns height is greater than the other. It seems that bootstrap is adding some additional padding/margin to the checkboxes that I am unable to figure out (see image below). If I remove checkboxes for text, the layout is fine. Is there a way to make the second nested columns have the same height (Right bordered item in picture)? <link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"> <div class="container mt-3"> <div class="row"> <div class="col-2"> <div class="row"> <div class="col-4 d-flex justify-content-center"> <span class="">1</span> </div> <div class="col-4 d-flex justify-content-center"> <span class="">2</span> </div> <div class="col-4 d-flex justify-content-center"> <span class="">3</span> </div> </div> </div> <div class="col-10"> <div class="row"> <div class="col-2 d-flex"> <span>Service List</span> </div> <div class="col-8 text-center"> <span>Description</span> </div> <div class="col-1 px-1 text-start"> <span >Amount</span> </div> <div class="col-1"> <span></span> </div> </div> </div> </div> <div class="row"> <div class="col-2"> <div class="row align-items-center"> <div class="col-4 d-flex justify-content-center align-items-center "> <div class="form-check align-items-center d-flex justify-content-center align-items-center"> <input class="form-check-input" type="checkbox" value="{{obj.total}}" id="flexCheckDefault" checked> </div> </div> <div class="col-4 d-flex justify-content-center"> <div class="form-check d-flex justify-content-center align-items-center"> <input class="form-check-input" type="checkbox" value="{{obj.total}}" id="flexCheckDefault" checked> </div> </div> <div class="col-4 d-flex justify-content-center border"> <div class="form-check d-flex justify-content-center align-items-center"> <input class="form-check-input" type="checkbox" value="{{obj.total}}" id="flexCheckDefault" checked> </div> </div> </div> </div> <div class="col-10"> <div class="row align-items-center"> <div class="col-2 border"> <span>Line Item Name</span> </div> <div class="col-8"> <span>Line Item Description</span> </div> <div class="col-1"> <span>Total</span> </div> <div class="col-1"> <div class="form-check d-flex justify-content-center"> <input class="form-check-input align-self-center" type="checkbox" value="{{obj.total}}" id="flexCheckDefault" > </div> </div> </div> </div> </div>
My div content gets overlapped by the next div when i switch to small devices
I'm using bootstrap and when I'm switching to small devices my content gets overlapped by the next div. I tried to change everything and put margin on my bottom of my div but nothing seems to work. I'm missing something. I'm not sure if it something with the relative potitions I tried to add so I can add my svgs in the bottom of each div. The HTML <div class="container-fluid vh-100 " id="projects"> <!-- <div class="container d-flex h-100 " id="pwrap"> --> <div class="row align-items-center mx-auto " id="cards"> <div class="col-sm-6 col-lg-4 "> <div class="card" > <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> <div class=" col-sm-6 col-lg-4 "> <div class="card" > <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> <div class="col-sm-6 col-lg-4 "> <div class="card"> <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> </div> <svg class="botp" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="#FFB9B9" fill-opacity="1" d="M0,192L48,165.3C96,139,192,85,288,96C384,107,480,181,576,218.7C672,256,768,256,864,245.3C960,235,1056,213,1152,218.7C1248,224,1344,256,1392,272L1440,288L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg> <!-- </div> --> </div> <!-- /projects --> <!-- contact --> <div class="container-fluid w-100 vh-100 my-auto d-flex justify-content-center align-items-center " id="contact"> <!--Section: Contact v.2--> <div id="border-shadow"> <div class="border border-success p-3" id="bordercustom"> <section class="mb-4 " id="formcustom"> <!--Section heading--> <h2 class="h1-responsive font-weight-bold text-center my-4">Contact Me</h2> <div class="row justify-content-center"> <!--Grid column--> <div class="col-md-9 mb-md-0 mb-5"> <form id="contact-form" name="contact-form" action="mail.php" method="POST"> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-md-6"> <div class="md-form mb-0"> <input type="text" id="name" name="name" class="form-control"> <label for="name" class="">Your name</label> </div> </div> <!--Grid column--> <!--Grid column--> <div class="col-md-6"> <div class="md-form mb-0"> <input type="text" id="email" name="email" class="form-control"> <label for="email" class="">Your email</label> </div> </div> <!--Grid column--> </div> <!--Grid row--> <!--Grid row--> <div class="row"> <div class="col-md-12"> <div class="md-form mb-0"> <input type="text" id="subject" name="subject" class="form-control"> <label for="subject" class="">Subject</label> </div> </div> </div> <!--Grid row--> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-md-12"> <div class="md-form"> <textarea type="text" id="message" name="message" rows="2" class="form-control md-textarea"></textarea> <label for="message">Your message</label> </div> </div> </div> <!--Grid row--> </form> <div class="text-center text-md-left d-flex justify-content-center"> <a class="button mt-3" onclick="validateForm();"> <span class="default">Send</span> <span class="success">Sent</span> <div class="left"></div> <div class="right"></div> </a> </div> <div class="status"></div> </div> <!--Grid column--> </div> </div> </section> <!--Section: Contact v.2--> </div> <svg class="botc"xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="#363C62" fill-opacity="1" d="M0,288L60,272C120,256,240,224,360,224C480,224,600,256,720,277.3C840,299,960,309,1080,293.3C1200,277,1320,235,1380,213.3L1440,192L1440,320L1380,320C1320,320,1200,320,1080,320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z"></path></svg> </div> <!-- /contact --> and my css #home, #about, #projects, #contact{ position: relative; } #projects .botp{ z-index: 1; position: absolute; bottom: 0; left:0; } #cards{ z-index: 2; } #contact .botc{ position: absolute; bottom: 0; left:0; }
What browser are you using? I've run your code, and it's not overlapping (I'm using Opera/Google Chrome). Also, you can add height: auto to the divisions div, it may help :) EDIT: (I finally got what you mean) Just play with the z-index. Here is the code: CSS #home, #about, #projects, #contact { position: relative; } #projects .botp { z-index: 1; bottom: 0; left: 0; position: absolute; } #contact { z-index: 10; } #projects { z-index: 10; } .botc{ position: absolute; z-index: 1; left: 0; bottom: 200px; } #card-text { z-index: 10000; } .botp { position: absolute; z-index: 1; left: 0; bottom: 500px; z-index: 1; } .col-md-6 { z-index: 10; } index.html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container-fluid vh-100 " id="projects"> <!-- <div class="container d-flex h-100 " id="pwrap"> --> <div class="row align-items-center mx-auto " id="cards"> <div class="col-sm-6 col-lg-4 "> <div class="card"> <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> <div class="col-sm-6 col-lg-4"> <div class="card"> <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> <div class="col-sm-6 col-lg-4"> <div class="card"> <img src="pics/project1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title" style="z-index: 10;">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> Go somewhere </div> </div> </div> </div> </div> <svg class="botp" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"> <path fill="#FFB9B9" fill-opacity="1" d="M0,192L48,165.3C96,139,192,85,288,96C384,107,480,181,576,218.7C672,256,768,256,864,245.3C960,235,1056,213,1152,218.7C1248,224,1344,256,1392,272L1440,288L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"> </path> </svg> <!-- </div> --> <!-- /projects --> <!-- contact --> <div class="container-fluid w-100 vh-100 my-auto d-flex justify-content-center align-items-center " id="contact"> <!--Section: Contact v.2--> <div id="border-shadow"> <div class="border border-success p-3" id="bordercustom"> <section class="mb-4 " id="formcustom"> <!--Section heading--> <h2 class="h1-responsive font-weight-bold text-center my-4">Contact Me</h2> <div class="row justify-content-center"> <!--Grid column--> <div class="col-md-9 mb-md-0 mb-5"> <form id="contact-form" name="contact-form" action="mail.php" method="POST"> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-md-6"> <div class="md-form mb-0"> <input type="text" id="name" name="name" class="form-control"> <label for="name" class="">Your name</label> </div> </div> <!--Grid column--> <!--Grid column--> <div class="col-md-6"> <div class="md-form mb-0"> <input type="text" id="email" name="email" class="form-control"> <label for="email" class="">Your email</label> </div> </div> <!--Grid column--> </div> <!--Grid row--> <!--Grid row--> <div class="row"> <div class="col-md-12"> <div class="md-form mb-0"> <input type="text" id="subject" name="subject" class="form-control"> <label for="subject" class="">Subject</label> </div> </div> </div> <!--Grid row--> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-md-12"> <div class="md-form"> <textarea type="text" id="message" name="message" rows="2" class="form-control md-textarea"></textarea> <label for="message">Your message</label> </div> </div> </div> <!--Grid row--> </form> <div class="text-center text-md-left d-flex justify-content-center"> <a class="button mt-3" onclick="validateForm();"> <span class="default">Send</span> <span class="success">Sent</span> <div class="left"></div> <div class="right"></div> </a> </div> <div class="status"></div> </div> <!--Grid column--> </div> </div> </section> <!--Section: Contact v.2--> </div> </div> <!-- /contact --> <svg class="botc" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"> <path fill="#363C62" fill-opacity="1" d="M0,288L60,272C120,256,240,224,360,224C480,224,600,256,720,277.3C840,299,960,309,1080,293.3C1200,277,1320,235,1380,213.3L1440,192L1440,320L1380,320C1320,320,1200,320,1080,320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z"> </path> </svg> </body> </html> Hope this helps :)
so i randomly fixed it just by adding this code on css .card-img-top { width: 100%; height: 15vw; object-fit: cover; }
Issue with bootstrap columns while nesting inside columns
The layout of page is miss-placed when columns are nested inside another column <div class="container"> <div class="row"> <div class="col-6"> <div class="col-6"> <label>Name</label> <input type="text" class="form-control" /> </div> <div class="col-6"> <label>Name</label> <input type="text" class="form-control" /> </div> </div> <div class="col-6"></div> </div> </div>
<div class="container"> <div class="row"> <div class="col-6"> <div class="row"> <div class="col-6"> <label>Name</label> <input type="text" class="form-control" /> </div> <div class="col-6"> <label>Name</label> <input type="text" class="form-control" /> </div> </div> </div> <div class="col-6"></div> </div> </div> An advanced way: <div class="container bg-primary" style="width: 800px; height: 100px; "> <div class="row ml-1 h-100"> <div class="col-10 ml-0 my-auto h-75 container bg-danger"> <div class="row ml-1 h-100"> <div class="col-8 ml-0 my-auto h-75 container bg-warning"> <div class="row ml-1 h-100"> <div class="col-6 ml-0 my-auto h-75 container bg-success"> <div class="row ml-1 h-100"> <div class="col-4 ml-0 my-auto h-75 container bg-dark"> </div> </div> </div> </div> </div> </div> </div> </div> </div>
Absolute div under footer
When I add a footer field under the div, which is absolute value, this field escapes on mobile and desktop. Also, iframe doesn't have full height. What should I do? All details are given in the attachment. When I add a footer field under the div, which is absolute value, this field escapes on mobile and desktop. Also, iframe doesn't have full height. What should I do? All details are given in the attachment. Attach: My Code: .contact-form { position: absolute; z-index: 100; left: 0; right: 0; margin-top: 20em; } .form { background: #fff; border-radius: 1em; padding: 3em; } .maps { z-index: 0; position: relative; -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter: grayscale(100%); width: 100%; overflow: hidden; margin-bottom: -1em; } .maps iframe { width: 100%; overflow: hidden; height: 100vh; } <div class="contact-form"> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="form mt-5 mb-5 d-flex flex-md-row flex-column"> <div class="col-md-5 mt-5"> <h4>İletişim</h4> <div id="title" class="mt-5 d-flex"> <h6><i class="fas fa-paper-plane mr-2"></i>E-Posta: baris#reklamodasi.com.tr</h6> </div> <div id="title" class="mt-4 d-flex"> <h6><i class="fas fa-phone-alt mr-2"></i>Telefon Numarası: +90 534 613 72 62</h6> </div> <div id="title" class="mt-4 d-flex"> <h6><i class="fas fa-sort-numeric-up mr-2"></i>Sicil Numarası: 000010001011111100</h6> </div> <div id="title" class="mt-4 d-flex"> <h6><i class="fas fa-sort-numeric-down mr-2"></i>Mersis Numarası: 000010001011111100</h6> </div> <p class="mt-5" style="color: #939393;"><i class="fas fa-map-marker mr-2" style="color: #0097b1;"></i>Küçükbakkalköy Mh. Küçük Setli Sokak Denge Panorama Plaza. No: 5-9 Kat: 3 D:13 34750, Ataşehir - İstanbul</p> </div> <div class="col-md-7 mt-5 mb-4"> <div class="d-block"> <div class="input-group mb-3 mr-2"> <input type="text" class="form-control" placeholder="Adınız Soyadınız" aria-label="ad-soyad" aria-describedby="basic-addon1"> </div> <div class="input-group mb-3"> <input type="text" class="form-control" placeholder="E-Posta" aria-label="e-mail" aria-describedby="basic-addon1"> </div> </div> <div class="form-group"> <label for="exampleFormControlTextarea1"></label> <textarea placeholder="Mesajınız" class="form-control" id="exampleFormControlTextarea1" rows="10"></textarea> </div> <button style="width: 100%;" type="button" class="btn btn-sincap"><i class="far fa-paper-plane mr-2"></i>Gönder</button> </div> </div> </div> </div> </div> </div> <div class="maps"> <div class="row"> <div class="col-md-12"> <iframe class="map_h" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d24095.133376834387!2d29.11235246540525!3d40.98385285407077!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x2e8746b0ec51372a!2sReklam%20Odas%C4%B1!5e0!3m2!1str!2str!4v1595930989510!5m2!1str!2str" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" tabindex="0"></iframe> </div> </div> </div> <div class="footer pb-5 text-center"> <div class="container"> <div class="row"> <div class="col-md-12 copy"> <img src="/materials/logo.svg" width="90px" height="90px"> </div> <div class="col-md-12"> <p>All Rights Reserved 2020 | Reklam Odası</p> </div> </div> </div> </div> thank you so much this works little bit but this time it looks like this. Vikas Katal
When you absolute an element relative to another element try to wrap both by a parent element. It will automatically fix many issues you may face in the future. <div class="form-map-wrapper"> <div class="contact-form"> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="form mt-5 mb-5 d-flex flex-md-row flex-column"> <div class="col-md-5 mt-5"> <h4>İletişim</h4> <div id="title" class="mt-5 d-flex"><h6><i class="fas fa-paper-plane mr-2"></i>E-Posta: baris#reklamodasi.com.tr</h6></div> <div id="title" class="mt-4 d-flex"><h6><i class="fas fa-phone-alt mr-2"></i>Telefon Numarası: +90 534 613 72 62</h6></div> <div id="title" class="mt-4 d-flex"><h6><i class="fas fa-sort-numeric-up mr-2"></i>Sicil Numarası: 000010001011111100</h6></div> <div id="title" class="mt-4 d-flex"><h6><i class="fas fa-sort-numeric-down mr-2"></i>Mersis Numarası: 000010001011111100</h6></div> <p class="mt-5" style="color: #939393;"><i class="fas fa-map-marker mr-2" style="color: #0097b1;"></i>Küçükbakkalköy Mh. Küçük Setli Sokak Denge Panorama Plaza. No: 5-9 Kat: 3 D:13 34750, Ataşehir - İstanbul</p> </div> <div class="col-md-7 mt-5 mb-4"> <div class="d-block"> <div class="input-group mb-3 mr-2"> <input type="text" class="form-control" placeholder="Adınız Soyadınız" aria-label="ad-soyad" aria-describedby="basic-addon1"> </div> <div class="input-group mb-3"> <input type="text" class="form-control" placeholder="E-Posta" aria-label="e-mail" aria-describedby="basic-addon1"> </div> </div> <div class="form-group"> <label for="exampleFormControlTextarea1"></label> <textarea placeholder="Mesajınız" class="form-control" id="exampleFormControlTextarea1" rows="10"></textarea> </div> <button style="width: 100%;" type="button" class="btn btn-sincap"><i class="far fa-paper-plane mr-2"></i>Gönder</button> </div> </div> </div> </div> </div> </div> <div class="maps"> <div class="row"> <div class="col-md-12"> <iframe class="map_h" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d24095.133376834387!2d29.11235246540525!3d40.98385285407077!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x2e8746b0ec51372a!2sReklam%20Odas%C4%B1!5e0!3m2!1str!2str!4v1595930989510!5m2!1str!2str" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" tabindex="0"></iframe> </div> </div> </div> </div> Also add z-index wisely to relative and absolute elements because it can effect badly for other elements (Ex:- for Fixed Menu) .form-map-wrapper { position: relative; z-index: 1; } .maps { position: absolute; z-index: 1; }
Materialize - Button in Card won't go center
I have a card in which there is button (Start button) which won't go to the center of the card. I tried center-align class, but that won't do it. I also tried using my id and class and trying text-align: center; in my css. But that did not work either. Don't know what I'm missing. Here is what I have: This is what I want: Here is the full html: <!DOCTYPE html> <html> <head> <!--Import Google Icon Font--> <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <link rel="stylesheet" type="text/css" href="css/style.css"> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--navbar--> <header> <nav> <div class="nav-wrapper light-blue darken-3"> Kviz <!-- <ul id="nav-mobile" class="left hide-on-med-and-down"> <li>test</li> </ul> --> </div> </nav> </header> <main> <div class="row"> <div class="col s12 m12 l6 xl6"> <div class="card"> <div class="card-image waves-effect waves-block waves-light"> <img class="activator" src="images/kvizslika.jpg"> </div> <div class="card-content"> <span class="card-title activator grey-text text-darken-4">Kako se radi kviz ? <a class="waves-effect light-blue darken-3 btn activator right">Instrukcije</a> </span> </div> <div class="card-reveal"> <span class="card-title grey-text text-darken-4">Instrukcije<i class="material-icons right">close</i></span> <p>Here is some more information about this product that is only revealed once clicked on.</p> <div class="card-tabs"> <ul class="tabs tabs-fixed-width"> <li class="tab"><a class="active" href="#korak1">Poeni</a></li> <li class="tab">Odgovori</li> <li class="tab">Vreme</li> </ul> </div> <div class="card-content grey lighten-4"> <div id="korak1">Test 1. Bla bla. <br/> Bla bla.</div> <div id="korak2">Test 2</div> <div id="korak3">Test 3</div> </div> </div> </div> </div> <div class="col s12 m12 l6 xl6"> <div class="card"> <div class="row"> <div class="col s12 m12"> <div class="card light-blue darken-3"> <div class="card-content white-text"> <span class="card-title naslovPrijava">Prijava</span> </div> </div> </div> <div class="col s12 m12"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 1:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name" type="text" class="validate"> <label for="first_name">Ime</label> </div> <div class="input-field"> <input id="last_name" type="text" class="validate"> <label for="last_name">Prezime</label> </div> </form> </div> </div> </div> <div class="col s6 m6"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 2:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name2" type="text" class="validate"> <label for="first_name2">Ime</label> </div> <div class="input-field"> <input id="last_name2" type="text" class="validate"> <label for="last_name2">Prezime</label> </div> </form> </div> </div> </div> <div class="col s6 m6"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 3:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name3" type="text" class="validate"> <label for="first_name3">Ime</label> </div> <div class="input-field"> <input id="last_name3" type="text" class="validate"> <label for="last_name3">Prezime</label> </div> </form> </div> </div> </div> </div> <button class="btn-large waves-effect waves-light light-blue darken-3 dugmeStart" type="submit" name="action">Start <i class="material-icons right">send</i> </button> </div> </div> </div> </div> </main> <footer class="page-footer light-blue darken-4"> <div class="footer-copyright"> <div class="container"> <center> © 2017 VTŠ Apps Team </center> </div> </div> </footer> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> </body> </html> Here is the full css: body { display: flex; min-height: 100vh; flex-direction: column; background-color: rgb(232,232,232); } main { flex: 1 0 auto; } .tabs .tab a{ color:#00ACC1; } .tabs .tab a:hover,.tabs .tab a.active { background-color:transparent; color:#00ACC1; } .tabs .tab.disabled a,.tabs .tab.disabled a:hover { color:rgba(102,147,153,0.7); } .tabs .indicator { background-color:#00ACC1; } .naslovPrijava{ font-size: 20px !important; text-align: center; height: 18px; } .naslovUcesnik{ font-size: 18px !important; text-align: left; margin-left:-15px; margin-top: -15px; } .pomeriKarticu{ margin-left:-35px; height: 50px; } .dugmeStart{ text-align: center; }
You have to use the center-align class on a parent element of the button, so I added a parent with class="center-align" body { display: flex; min-height: 100vh; flex-direction: column; background-color: rgb(232, 232, 232); } main { flex: 1 0 auto; } .tabs .tab a { color: #00ACC1; } .tabs .tab a:hover, .tabs .tab a.active { background-color: transparent; color: #00ACC1; } .tabs .tab.disabled a, .tabs .tab.disabled a:hover { color: rgba(102, 147, 153, 0.7); } .tabs .indicator { background-color: #00ACC1; } .naslovPrijava { font-size: 20px !important; text-align: center; height: 18px; } .naslovUcesnik { font-size: 18px !important; text-align: left; margin-left: -15px; margin-top: -15px; } .pomeriKarticu { margin-left: -35px; height: 50px; } .dugmeStart { text-align: center; } <!DOCTYPE html> <html> <head> <!--Import Google Icon Font--> <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </head> <body> <!--navbar--> <header> <nav> <div class="nav-wrapper light-blue darken-3"> Kviz <!-- <ul id="nav-mobile" class="left hide-on-med-and-down"> <li>test</li> </ul> --> </div> </nav> </header> <main> <div class="row"> <div class="col s12 m12 l6 xl6"> <div class="card"> <div class="card-image waves-effect waves-block waves-light"> <img class="activator" src="images/kvizslika.jpg"> </div> <div class="card-content"> <span class="card-title activator grey-text text-darken-4">Kako se radi kviz ? <a class="waves-effect light-blue darken-3 btn activator right">Instrukcije</a> </span> </div> <div class="card-reveal"> <span class="card-title grey-text text-darken-4">Instrukcije<i class="material-icons right">close</i></span> <p>Here is some more information about this product that is only revealed once clicked on.</p> <div class="card-tabs"> <ul class="tabs tabs-fixed-width"> <li class="tab"><a class="active" href="#korak1">Poeni</a></li> <li class="tab">Odgovori</li> <li class="tab">Vreme</li> </ul> </div> <div class="card-content grey lighten-4"> <div id="korak1">Test 1. Bla bla. <br/> Bla bla.</div> <div id="korak2">Test 2</div> <div id="korak3">Test 3</div> </div> </div> </div> </div> <div class="col s12 m12 l6 xl6"> <div class="card"> <div class="row"> <div class="col s12 m12"> <div class="card light-blue darken-3"> <div class="card-content white-text"> <span class="card-title naslovPrijava">Prijava</span> </div> </div> </div> <div class="col s12 m12"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 1:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name" type="text" class="validate"> <label for="first_name">Ime</label> </div> <div class="input-field"> <input id="last_name" type="text" class="validate"> <label for="last_name">Prezime</label> </div> </form> </div> </div> </div> <div class="col s6 m6"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 2:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name2" type="text" class="validate"> <label for="first_name2">Ime</label> </div> <div class="input-field"> <input id="last_name2" type="text" class="validate"> <label for="last_name2">Prezime</label> </div> </form> </div> </div> </div> <div class="col s6 m6"> <div class="card"> <div class="card-content"> <div class="row"> <div class="col s6 m6"> <div class="card pomeriKarticu light-blue darken-3 center"> <div class="card-content white-text"> <span class="card-title naslovUcesnik">Učesnik 3:</span> </div> </div> </div> </div> <form> <div class="input-field"> <input id="first_name3" type="text" class="validate"> <label for="first_name3">Ime</label> </div> <div class="input-field"> <input id="last_name3" type="text" class="validate"> <label for="last_name3">Prezime</label> </div> </form> </div> </div> </div> </div> <div class="center-align"> <button class="btn-large waves-effect waves-light light-blue darken-3 dugmeStart" type="submit" name="action">Start <i class="material-icons right">send</i> </button> </div> </div> </div> </div> </div> </main> <footer class="page-footer light-blue darken-4"> <div class="footer-copyright"> <div class="container"> <center> © 2017 VTŠ Apps Team </center> </div> </div> </footer> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> </body> </html>
You can use margin to achieve this also .dugmeStart { text-align: center; display: block;/**Added This**/ margin: 0 auto; /**Added This**/ }