Position div in flexbox aligned layout - html

Below is the layout, I have used the following styles to push the footer to the bottom, it is very important the footer is anchored to the bottom:
.body {
height: 100vh;
display: flex;
flex-direction: column;
}
.container {
flex: 1 0 auto;
}
I have then used the following styles to try and position the login form vertically between the banner and the footer but is not quite right. The same layout is used by multiple forms of varying heights.
The login-layout__positioner class is my attempt to position it vertically:
.login-layout__positioner {
display: -ms-flexbox;
display: flex;
-ms-flex-pack: center;
justify-content: center;
-ms-flex-align: center;
align-items: center;
position: absolute;
top: 0%;
left: 0;
right: 0;
bottom: 0;
}
How can I vertically align the form between the banner and the footer which takes into account different heights for the middle form?
html, body, #global__root, .global__main-content {
height: 100%;
}
.login-layout__positioner {
display: -ms-flexbox;
display: flex;
align-items: center;
position: absolute;
top: -6.5%;
left: 0;
right: 0;
bottom: 0;
}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
}
.app-layout__container {
flex: 1 0 auto;
}
.banner__container {
color: #fff;
background-color: #0065bd;
}
.banner__top {
padding-top: 22px;
}
.login-layout__container {
background-color: inherit;
width: 100%;
}
wrapper {
max-width: 750px;
margin: 0 auto;
padding: 0 15px;
}
.login-layout__positioner {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.login-layout__form {
padding-left: 0;
}
.medium--eight-twelfths {
width: 66.666%;
}
.login-layout__inner__container {
padding: 0px 30px 30px;
}
.footer__footer {
text-align: left;
color: #fff;
}
.footer__footer {
padding-top: 48px;
padding-bottom: 48px;
}
.footer__footer {
font-size: 19px;
}
.footer__footer {
background-color: #0065bd;
margin-top: 48px;
text-align: center;
font-weight: 700;
font-size: 16px;
padding-top: 16px;
padding-bottom: 16px;
text-align: center;
}
.footer__footer ul {
list-style: none;
margin-left: 0;
}
.footer__footer a,
.footer__footer a:hover,
.footer__footer a:focus,
.footer__footer a:active {
outline: 0;
color: #fff;
}
<div class="app-layout__body">
<div class="wrapper login-layout__container">
<div class="banner__container">
<div class="wrapper banner__top">
<div class="grid">
<div class="grid__item large--one-third banner__grid-item-left">logo</div>
<div class="grid__item large--two-thirds ">
<h2 class="banner__heading-right"> </h2>
</div>
</div>
</div>
</div>
<div class="grid login-layout__positioner">
<div class="grid__item medium--two-thirds login-layout__form">
<div class="login-layout__inner__container">
<div class="grid">
<div class="grid__item ">
<h2 class="">Sign In</h2>
</div>
</div>
<form>
<div>
<div class="grid">
<div class="grid__item ">
<div class="form-group form-control__input">
<label for="email" id="email-label" class="label__default label__strong label__double-margin">Email</label>
<div class="input-wrapper">
<input type="text" autocomplete="off" class="input__default form-control" id="email" name="email" aria-invalid="false" aria-describedby="email-error" value="">
</div>
</div>
</div>
</div>
<div class="grid">
<div class="grid__item ">
<div class="form-group form-control__input">
<label for="password" id="password-label" class="label__default label__strong label__double-margin">Password</label>
<div class="input-wrapper ">
<input type="password" autocomplete="off" class="input__default form-control" id="password" name="password" value="">
</div>
</div>
</div>
</div>
<div class="grid login__button__container">
<div class="grid__item large--two-thirds "><a tabindex="0" href="/business/forgotten-password">Forgotten your password?</a></div>
<div class="grid__item medium--one-third ">
<button class="button__default button__primary" type="submit">LOGIN</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer__footer">
<div class="wrapper">
<div class="grid">
<div class="grid__item ">
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</footer>

Sorry, I had to remove about 80% of your div tree because I just couldn't wrap my head around so much stuff.
Here's a simple column layout with a header, a footer and a centered form.
html, body {margin:0}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
header, footer {
min-height: 20vh;
background: blue;
color: white;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
footer ul li a {
color: white;
}
form {
border: green dashed 2px;
}
<div class="app-layout__body">
<header>
<div class="grid__item large--one-third banner__grid-item-left">logo</div>
</header>
<form>
<h2>Sign in</h2>
<p>Email</p>
<input>
<p>Password</p>
<input>
<button>Login</button>
</form>
<footer class="footer__footer">
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</footer>
</div>

Related

overflow scroll not adjusting height of div

My issue:
I'm making somewhat of a Zillow clone. I need the page to not expand beyond 100% of the viewport height however, I'm making a section with the intentions of having the overflow property set to scroll. When I do this, the section expands beyond the viewport height and leaves a large whitespace at the bottom of my page. I can adjust the height to fill up to 100vh however, if I adjust the screen vertically the div with the scroll overflow doesn't adjust to the viewport height. Thanks for any and all help!
Here's a screenshot of my issue:
The circled section is the section that I need the overflow to scroll:
This is my HTML for the entire 'popup' portion:
<div class="home__popup--backdrop">
<div class="home__popup--container">
<div class="home__popup--left">
<div class="home__popup--img--container">
<div class="home__popup--img--main--container">
<img src="./src/img/home-0.jpg" alt="home-0" class="home__popup--img--main">
</div>
<div class="home__popup--img--sub--container">
<img src="./src/img/home-1.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-2.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-3.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-4.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-5.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-0.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-1.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-2.jpg" alt="home-0" class="home__popup--img--sub">
</div>
</div>
</div>
<div class="home__popup--right">
<div class="home__popup--header--container">
<div class="home__popup--logo--container">
<div class="logo__container--home">
<img src="./src/img/logo__house.svg" alt="logo-homes" class="logo logo__homes logo__homes--small">
</div>
<div class="logo__container--txt">
<img src="./src/img/logo__txt.svg" alt="logo-homes" class="logo logo__homes logo__txt--small">
</div>
</div>
<div class="home__popup--social--container">
<div class="home__popup--social">
<img src="./src/img/like.svg" alt="logo like" class="popup__logo logo__like">
<p>Save</p>
</div>
<div class="home__popup--share">
<div class="home__popup--social">
<img src="./src/img/next.svg" alt="logo next" class="popup__logo logo__next">
<p>Share</p>
</div>
</div>
<div class="home__popup--more">
<div class="home__popup--social">
<img src="./src/img/more.svg" alt="logo more" class="popup__logo logo__more">
<p>More</p>
</div>
</div>
</div>
</div>
<div class="home__popup--details--container">
<div class="home__popup--details">
<p class="home__popup--price">$500,000</p>
<p class="home__popup--beds home__popup--details--home">3 <span>bds</span></p>
<p class="home__popup--baths home__popup--details--home">2 <span>ba</span></p>
<p class="home__popup--sqft home__popup--details--home">2,245 <span>sqft</span></p>
</div>
<div class="home__popup--address--container">
<p class="home__popup--address">
4210 sharman rd<span>,&nbsp</span>
</p>
<p class="home__popup--city">Madison<span>,&nbsp</span></p>
<p class="home__popup--state">WI</p>
</div>
<div class="home__popup--btn--container">
<button class="btn__agent">Contact Agent</button>
</div>
</div>
<div class="home__popup--overview--container">
<div class="home__popup--overview--container--links">
<img src="./src/img/001-left-arrow.svg" alt="arrow-left" class = 'arrow-small arrow-small--left'>
<div class="home__popup--overview home__popup--overview--active home__popup--overview--container--links--text--container" data-list-section = 0>
<p class="home__popup--overview--text home__popup--overview--container--links--text">Overview</p>
</div>
<div class="home__popup--facts home__popup--overview--container--links--text--container">
<p class="home__popup--facts--text home__popup--overview--container--links--text">Facts and features</p>
</div>
<div class="home__popup--value home__popup--overview--container--links--text--container">
<p class="home__popup--value--text home__popup--overview--container--links--text">Home value</p>
</div>
<div class="home__popup--history home__popup--overview--container--links--text--container" data-list-section = 1>
<p class="home__popup--history--text home__popup--overview--container--links--text">Price and tax history</p>
</div>
<div class="home__popup--monthly home__popup--overview--container--links--text--container">
<p class="home__popup--monthly--text home__popup--overview--container--links--text">Monthly cost</p>
</div>
<div class="home__popup--rental home__popup--overview--container--links--text--container">
<p class="home__popup--rental--text home__popup--overview--container--links--text">Rental Value</p>
</div>
<div class="home__popup--schools home__popup--overview--container--links--text--container" data-list-section = 2>
<p class="home__popup--schools--text home__popup--overview--container--links--text">Nearby schools</p>
</div>
<div class="home__popup--similar home__popup--overview--container--links--text--container">
<p class="home__popup--similar--text home__popup--overview--container--links--text">Similar homes</p>
</div>
<div class="home__popup--neighborhood home__popup--overview--container--links--text--container">
<p class="home__popup--neighborhood--text home__popup--overview--container--links--text">Neighborhood</p>
</div>
<div class="home__popup--homes-for-you home__popup--overview--container--links--text--container">
<p class="home__popup--homes-for-you--text home__popup--overview--container--links--text">Homes for you</p>
</div>
<img src="./src/img/002-right-arrow.svg" alt="arrow-right" class = 'arrow-small arrow-small--right'>
</div>
<div class="home__popup--scroll">
<div class="home__popup--home--detail--container">
<div class="home__popup--map--container">
<div class="test" id = "home__popup--map"></div>
</div>
<div class="home__popup--text--container">
<div class="home__popup--text--stats">
<P class="home__popup--text--header">Overview</P>
<div class="home__popup--text--user-activity">
<p class="home__popup--text--time">Time on Home Finder &nbsp<span> --</span></p>
<p class="home__popup--text--views">Views <span>64</span></p>
<p class="home__popup--text--saves">Saves <span>1</span></p>
</div>
<p class="home__popup--text--description">
No showings until 8/22 OH.....
</p>
<p class="home__popup--text--read-more">Read more</p>
</div>
<p class="home__popup--text--open-house--header">Open House</p>
<p class="home__popup--text--open-house--day">Sun, Aug 22</p>
<p class="home__popup--text--open-house--time">12:00 PM - 2:00 PM</p>
<ul class="home__popup--text--agent--container">
<li class="home__popup--text--agent">Kavita Biyani</li>
<li class="home__popup--text--agent">Nik Tantardini</li>
<li class="home__popup--text--agent">First Weber INC</li>
<li class="home__popup--text--agent">Lena Oberwetter</li>
<li class="home__popup--text--agent">Prince Michael</li>
</ul>
<div class="home__popup--overview--text">
</div>
<div class="home--popup--overview--specs">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here's the HTML for the overflowed portion:
<div class="home__popup--scroll">
<div class="home__popup--home--detail--container">
<div class="home__popup--map--container">
<div class="test" id = "home__popup--map"></div>
</div>
<div class="home__popup--text--container">
<div class="home__popup--text--stats">
<P class="home__popup--text--header">Overview</P>
<div class="home__popup--text--user-activity">
<p class="home__popup--text--time">Time on Home Finder &nbsp<span> --</span></p>
<p class="home__popup--text--views">Views <span>64</span></p>
<p class="home__popup--text--saves">Saves <span>1</span></p>
</div>
<p class="home__popup--text--description">
No showings until 8/22 OH. Amazing opportunity ...
</p>
<p class="home__popup--text--read-more">Read more</p>
</div>
<p class="home__popup--text--open-house--header">Open House</p>
<p class="home__popup--text--open-house--day">Sun, Aug 22</p>
<p class="home__popup--text--open-house--time">12:00 PM - 2:00 PM</p>
<ul class="home__popup--text--agent--container">
<li class="home__popup--text--agent">Kavita Biyani</li>
<li class="home__popup--text--agent">Nik Tantardini</li>
<li class="home__popup--text--agent">First Weber INC</li>
<li class="home__popup--text--agent">Lena Oberwetter</li>
<li class="home__popup--text--agent">Prince Michael</li>
</ul>
<div class="home__popup--overview--text">
</div>
<div class="home--popup--overview--specs">
</div>
</div>
</div>
Here is the relevant css:
.home__popup {
&--home--detail--container {
}
&--text {
&--description{
font-size: 1.8rem;
font-weight: 300;
color: $color-grey-text;
line-height: 1.3;
}
&--user-activity{
display: flex;
margin-bottom: 2rem;
font-size: 1.4rem;
color: $color-grey-text;
& span{
color: black;
}
}
&--time{
margin-right: 2rem;
border-right: 1px solid $color-grey-medium;
& span{
font-weight: bold;
margin-right: 2rem;
}
}
&--saves{
margin-left: 2rem;
& span{
font-weight: bold;
}
}
&--views{
margin-right: 2rem;
border-right: 1px solid $color-grey-medium;
& span{
font-weight: bold;
margin-right: 2rem;
}
}
&--header {
font-size: 2rem;
font-weight: 700;
letter-spacing: 0.5px;
margin-bottom: 2rem;
}
&--container {
margin-top: 2rem;
display: flex;
flex-direction: column;
margin-left: 1rem;
}
}
&--btn {
&--container {
margin-top: 1rem;
margin-left: 1rem;
display: flex;
justify-content: space-between;
width: 100%;
position: relative;
}
}
&--address {
&--container {
display: flex;
font-weight: 300;
font-size: 1.6rem;
margin-left: 1rem;
margin-top: 1rem;
}
}
&--baths {
margin-left: 0.5rem;
}
&--beds {
margin-left: 2rem;
}
&--price {
margin-top: 3rem;
font-size: 2.5rem;
font-weight: 500;
margin-left: 1rem;
}
&--social {
cursor: pointer;
&--container {
display: flex;
align-items: center;
width: 45%;
justify-content: space-around;
}
}
&--backdrop {
width: 100vw;
height: 100vh;
z-index: 2999;
position: absolute;
top: 0;
left: 0;
backdrop-filter: blur(2px);
background-color: rgba(0, 0, 0, 0.671);
}
&--container {
position: absolute;
top: 0;
left: 50%;
height: 100vh;
width: 65vw;
background-color: white;
transform: translateX(-50%);
z-index: 3000;
backdrop-filter: blur(2px);
display: flex;
flex-direction: row;
}
&--left {
position: relative;
width: 60%;
overflow-y: scroll;
}
&--right {
width: 40%;
position: relative;
}
&--img {
&--main {
height: auto;
object-fit: cover;
width: 100%;
}
&--sub {
height: 25rem;
object-fit: cover;
width: 49.5%;
margin-bottom: 0.4rem;
&--container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
}
}
&--header {
&--container {
display: flex;
justify-content: space-between;
position: relative;
border-bottom: 1px solid #6060607a;
margin-left: 1rem;
margin-right: 1rem;
}
}
&--logo {
&--container {
display: flex;
transform: translateY(1rem);
}
&__homes {
&--small {
height: 6rem;
width: 7rem;
}
}
}
&--details {
display: flex;
align-items: flex-end;
&--container {
display: flex;
flex-direction: column;
position: relative;
}
&--home {
font-size: 1.6rem;
font-weight: 400;
& span {
border-right: 1px solid $color-grey-text;
padding-right: 0.5rem;
font-weight: 300;
}
}
}
&--sqft {
margin-left: 0.5rem;
& span {
border-right: none;
}
}
&--overview {
color: $color-primary;
border-bottom: 2px solid $color-primary;
&--container {
display: flex;
flex-direction: column;
position: relative;
&--links {
display: flex;
overflow-x: scroll;
font-size: 14px;
font-weight: 300;
height: 5rem;
align-items: center;
margin-top: 2rem;
border-top: 1px solid $color-grey-medium;
border-bottom: 1px solid $color-grey-medium;
margin-left: 0.5rem;
margin-right: 0.5rem;
&::-webkit-scrollbar {
display: none;
}
&--text {
margin-left: 1rem;
margin-right: 1rem;
width: max-content;
&--container {
cursor: pointer;
height: 100%;
display: flex;
align-items: center;
transition: .2s all;
&:hover {
color: $color-primary-light;
}
}
}
}
}
}
}
I was having way too many issues out of pure stubbornness of not wanting to change my css however, I finally gave in and refactored the section as a grid. I'm now able to get it to function properly. Here's what it looks like:
And here's the css for the grid-layout:
&--right {
width: 40%;
position: relative;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 5rem 20rem 5rem auto;
}
here's the CSS for the updated div containing the scroll bar:
&--scroll{
grid-column: 1/-1;
grid-row: 4/5;
overflow-y: scroll;
overflow-x: hidden;
}

How to fix a footer which was designed using flexbox

I'm trying to clone the Google home page and I designed the footer using flexbox, but now I can't position it at the bottom of the page. How can I fix that or is there any other technique to tackle this problem.
Here is the screenshot and code of the page. I know it's messy and lack of design. First I just want to get the structure right.
screenshot of the page
```html
<body>
<div class="heading">
<div></div>
<div class="gmail">
<p>Gmail</p>
</div>
<div class="images">
<p>images</p>
</div>
<div class="gapps">
<button></button>
</div>
<div class="dp">
<p>dp</p>
</div>
</div>
<div class="container">
<div class="google-logo">
<img
src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
alt="Google logo"
/>
</div>
<div class="search-bar">
<input
type="search"
name="q"
aria-label="Search through site content"
/>
</div>
<div class="search-buttons">
<div class="search-button">
<button>Google Search</button>
</div>
<div class="feeling-lucky">
<button>I'm Feeling Lucky</button>
</div>
</div>
</div>
<div class="footer">
<div class="srilanka">
<p>Sri Lanka</p>
</div>
<div class="footer-bottom">
<div class="footer-bottom-left">
<div class="about">
<p>About</p>
</div>
<div class="advertising">
<p>Advertising</p>
</div>
<div class="business">
<p>Business</p>
</div>
<div class="how-search-works">
<p>How Search Works</p>
</div>
</div>
<div class="footer-bottom-right">
<div class="privacy">
<p>Privacy</p>
</div>
<div class="terms">
<p>Terms</p>
</div>
<div class="settings">
<p>Settings</p>
</div>
</div>
</div>
</div>
</body>
```
```css
body {
height: 100%;
}
body {
font-size: 14px;
font-family: arial, sans-serif;
color: #222;
}
.heading {
display: flex;
justify-content: flex-end;
padding-bottom: 100px;
}
.gmail {
padding: 0 15px;
}
.images {
padding: 0 15px;
}
.gapps {
padding: 0 15px;
}
.dp {
padding: 0 15px;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
}
.google-logo {
padding-bottom: 3vh;
}
.search-bar {
padding-bottom: 3vh;
}
.search-buttons {
display: flex;
justify-content: center;
}
.feeling-lucky {
padding-left: 2vh;
}
.footer {
display: flex;
flex-direction: column;
}
.footer-bottom {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.footer-bottom-left {
display: flex;
}
.srilanka {
padding: 0 15px;
}
.about {
padding: 0 15px;
}
.advertising {
padding: 0 15px;
}
.business {
padding: 0 15px;
}
.how-search-works {
padding: 0 15px;
}
.privacy {
padding: 0 15px;
}
.terms {
padding: 0 15px;
}
.settings {
padding: 0 15px;
}
.footer-bottom-right {
display: flex;
justify-items: flex-end;
}
```
Come on broh, add a lil bit of semantics there
<html>
<head></head>
<body>
<header></header>
<main></main>
<footer class=“footer”></footer>
</body>
It doesn’t matter if you use: flex, flow, grid
as those properties are defined with display. If you want to set your element at the bottom, we are talking about a position.
So you need to set its position
.footer {
position: fixed;
left:0;
bottom:0;
width:100%;
}
It's better to post your code as well, not just a screenshot.
btw you can use the following code on your footer and it will stick to the bottom of your page
footer{
position:fixed;
bottom: 0
width: 100%
}

divs overlapping each other

* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
background-color: #25274D;
font-family: "Trebuchet MS";
}
.link {
text-decoration: none;
color: whitesmoke;
float: left;
font-size: 20px;
font-weight: 700;
padding-right: 1vw;
padding-left: 1vw;
display: block;
transition: 0.4s;
height: 100%;
}
.link:hover {
background-color: #464866;
color: #2E9CCA;
}
a:link,
a:visited {
line-height: 7vh;
}
#top__nav {
text-decoration: none;
top: 0;
position: fixed;
width: 100%;
z-index: 10;
background-color: darkblue;
left: 0;
}
#top__nav__menu {
display: flex;
justify-content: flex-end;
padding-right: 20px;
list-style-type: none;
background-color: darkblue;
}
#logo {
float: left;
position: absolute;
left: 1vw;
}
.Gallery {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-top: 10vh;
position: relative;
}
.revealCard {
position: relative;
background-color: #25274D;
width: 45%;
height: 400px;
z-index: 1;
float: left;
border: 1px solid #464866;
perspective: 1000;
margin: 20px;
}
.card {
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: all 0.4s linear;
}
.revealCard:hover .card {
transform: rotateY(180deg);
}
.face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
color: #2E9CCA;
text-align: center;
font-size: 30px;
}
.face.back {
display: block;
transform: rotateY(180deg);
color: #2E9CCA;
text-align: center;
box-sizing: border-box;
padding: 20px auto;
}
.img {
width: 100%;
height: 100%;
}
#dynamicText {
max-width: 100%;
height: 30vh;
font-size: 40px;
}
.appearOnScroll {
color: #2E9CCA;
text-align: center;
padding: 20px 0;
}
#form {
margin-top: 90px;
display: block;
position: relative;
}
.form__fields {
margin-right: 20px;
color: #2E9CCA;
font-size: 25px;
padding: 20px;
}
.input {
position: absolute;
left: 20vw;
line-height: 30px;
color: black;
}
.input:focus {
background-color: #2E9CCA;
color: #25274D;
}
.star {
color: #2E9CCA;
}
.Fields {
padding-top: 20px;
}
<div id="top__nav">
<div id="card">
<ul id="top__nav__menu">
<img id="logo" src="NewProject/Logo.png">
<li><a class="link" href="#">Home</a></li>
<li><a class="link" href="#">Free Trial</a></li>
<li><a class="link" href="#">Samples</a></li>
<li><a class="link" href="#">Q-Bank</a></li>
<li><a class="link" href="#">Help</a></li>
</ul>
</div>
</div>
<div class="Gallery">
<div class="revealCard">
<div class="card">
<div class="face">
<p>Hey, hover to see the image.</p>
</div>
<div class="back face center">
<img class="img" src="https://images.unsplash.com/photo-1419064642531-e575728395f2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=67fd942ed774f3de1db50cf3dd0065eb&w=1000&q=80">
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<img class="img" src="https://i.ytimg.com/vi/TdpBRZ0dZhw/maxresdefault.jpg">
</div>
<div class="back face center">
<p>Here are the details of the image! Here are the details of the image! Here are the details of the image!</p>
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<img class="img" src="https://images.unsplash.com/photo-1419064642531-e575728395f2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=67fd942ed774f3de1db50cf3dd0065eb&w=1000&q=80">
</div>
<div class="back face center">
<p>Here are the details of the image! Here are the details of the image! Here are the details of the image!</p>
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<p>Hey, hover to see the image.</p>
</div>
<div class="back face center">
<img class="img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRcrkTylq_NcR1xOsclrGiDsbEPFpRFlLK_UxpB4zuF9O3Uvwu5">
</div>
</div>
</div>
</div>
<div id="dynamicText">
<p class="appearOnScroll">See the magic below!</p>
<p class="appearOnScroll">Signup For Your Free Beta Trial Today!</p>
<p class="appearOnScroll">This text appears on scroll</p>
<p class="appearOnScroll">This text appears on scroll</p>
<p class="appearOnScroll">This text appears on scroll</p>
</div>
<div id="form">
<form action="">
<div class="Fields">
<label class="form__fields">Full Name :<span class="star"> * </span></label>
<input class="input" type="text" name="full_name" placeholder="Enter your name" required><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 1:<span class="star"> * </span></label>
<input class="input" type="text" name="address_line_1" placeholder="Address line 1" required><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 2:</label>
<input class="input" type="text" name="address_line_2" placeholder="Address line 2"><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 3:</label>
<input class="input" type="text" name="address_line_3" placeholder="Address line 3"><br/>
</div>
<div class="Fields">
<label class="form__fields">Email :<span class="star"> * </span></label>
<input class="input" type="email" name="email" placeholder="Enter your E-mail" required><br/>
</div>
</form>
</div>
The form is coming on top of the text in the div #dynamicText, I have tried many things like removing position:absolute from or clear:both from everywhere but I couldn't fix it. Please help. Also it would be nice if I have to change the css properties of form element only. Thanks in advance.
The height property in the #dynamicText seems to be giving trouble. Removing it takes out the overlap. Alternatively, using min-height instead works as well.
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
background-color: #25274D;
font-family: "Trebuchet MS";
}
.link {
text-decoration: none;
color: whitesmoke;
float: left;
font-size: 20px;
font-weight: 700;
padding-right: 1vw;
padding-left: 1vw;
display: block;
transition: 0.4s;
height: 100%;
}
.link:hover {
background-color: #464866;
color: #2E9CCA;
}
a:link,
a:visited {
line-height: 7vh;
}
#top__nav {
text-decoration: none;
top: 0;
position: fixed;
width: 100%;
z-index: 10;
background-color: darkblue;
left: 0;
}
#top__nav__menu {
display: flex;
justify-content: flex-end;
padding-right: 20px;
list-style-type: none;
background-color: darkblue;
}
#logo {
float: left;
position: absolute;
left: 1vw;
}
.Gallery {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-top: 10vh;
position: relative;
}
.revealCard {
position: relative;
background-color: #25274D;
width: 45%;
height: 400px;
z-index: 1;
float: left;
border: 1px solid #464866;
perspective: 1000;
margin: 20px;
}
.card {
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: all 0.4s linear;
}
.revealCard:hover .card {
transform: rotateY(180deg);
}
.face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
color: #2E9CCA;
text-align: center;
font-size: 30px;
}
.face.back {
display: block;
transform: rotateY(180deg);
color: #2E9CCA;
text-align: center;
box-sizing: border-box;
padding: 20px auto;
}
.img {
width: 100%;
height: 100%;
}
#dynamicText {
max-width: 100%;
/*height: 30vh;*/
font-size: 40px;
}
.appearOnScroll {
color: #2E9CCA;
text-align: center;
padding: 20px 0;
}
#form {
margin-top: 90px;
display: block;
position: relative;
}
.form__fields {
margin-right: 20px;
color: #2E9CCA;
font-size: 25px;
padding: 20px;
}
.input {
position: absolute;
left: 20vw;
line-height: 30px;
color: black;
}
.input:focus {
background-color: #2E9CCA;
color: #25274D;
}
.star {
color: #2E9CCA;
}
.Fields {
padding-top: 20px;
}
<div id="top__nav">
<div id="card">
<ul id="top__nav__menu">
<img id="logo" src="NewProject/Logo.png">
<li><a class="link" href="#">Home</a></li>
<li><a class="link" href="#">Free Trial</a></li>
<li><a class="link" href="#">Samples</a></li>
<li><a class="link" href="#">Q-Bank</a></li>
<li><a class="link" href="#">Help</a></li>
</ul>
</div>
</div>
<div class="Gallery">
<div class="revealCard">
<div class="card">
<div class="face">
<p>Hey, hover to see the image.</p>
</div>
<div class="back face center">
<img class="img" src="https://images.unsplash.com/photo-1419064642531-e575728395f2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=67fd942ed774f3de1db50cf3dd0065eb&w=1000&q=80">
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<img class="img" src="https://i.ytimg.com/vi/TdpBRZ0dZhw/maxresdefault.jpg">
</div>
<div class="back face center">
<p>Here are the details of the image! Here are the details of the image! Here are the details of the image!</p>
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<img class="img" src="https://images.unsplash.com/photo-1419064642531-e575728395f2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=67fd942ed774f3de1db50cf3dd0065eb&w=1000&q=80">
</div>
<div class="back face center">
<p>Here are the details of the image! Here are the details of the image! Here are the details of the image!</p>
</div>
</div>
</div>
<div class="revealCard">
<div class="card">
<div class="face">
<p>Hey, hover to see the image.</p>
</div>
<div class="back face center">
<img class="img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRcrkTylq_NcR1xOsclrGiDsbEPFpRFlLK_UxpB4zuF9O3Uvwu5">
</div>
</div>
</div>
</div>
<div id="dynamicText">
<p class="appearOnScroll">See the magic below!</p>
<p class="appearOnScroll">Signup For Your Free Beta Trial Today!</p>
<p class="appearOnScroll">This text appears on scroll</p>
<p class="appearOnScroll">This text appears on scroll</p>
<p class="appearOnScroll">This text appears on scroll</p>
</div>
<div id="form">
<form action="">
<div class="Fields">
<label class="form__fields">Full Name :<span class="star"> * </span></label>
<input class="input" type="text" name="full_name" placeholder="Enter your name" required><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 1:<span class="star"> * </span></label>
<input class="input" type="text" name="address_line_1" placeholder="Address line 1" required><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 2:</label>
<input class="input" type="text" name="address_line_2" placeholder="Address line 2"><br/>
</div>
<div class="Fields">
<label class="form__fields">Address line 3:</label>
<input class="input" type="text" name="address_line_3" placeholder="Address line 3"><br/>
</div>
<div class="Fields">
<label class="form__fields">Email :<span class="star"> * </span></label>
<input class="input" type="email" name="email" placeholder="Enter your E-mail" required><br/>
</div>
</form>
</div>
Remove the height of the dynamicTest div which is set to 30vh. The overlapping divs is caused due to that property.

how do vertically align login form between banner and footer

Given I have the html and css in the snippet below the question, how can I vertically centre the login view no matter what screen height is?
I have tried this for the .login-layout__positioner class:
.login-layout__positioner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 42%;
transform: translateY(-42%);
}
But this does not centre well in large screen heights?
Is there a better way?
body {
height: 100%;
background-color: #f7f7f4;
}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
}
.app-layout__container {
flex: 1 0 auto;
}
.banner__container {
background-color: #fff
}
.banner__top {
padding-top: 15px;
}
.login-layout__container {
background-color: #f7f7f4;
width: 100%;
}
.login-layout__positioner {
text-align: center;
margin: auto;
}
footer {
background-color: #0065bd;
}
a {
color: #fff;
}
ul {
list-style: none;
margin-left: 0;
}
li {
display: inline;
}
.form__group {
background-color: #fff;
}
<body>
<div id="root">
<div class="main-content">
<div class="app-layout__body">
<div class="app-layout__container">
<div class="banner__container">
<div class="banner__top">
<div>
<div>
<h2>Banner</h2></div>
</div>
</div>
</div>
<div class="login-layout__container">
<div class="login-layout__positioner">
<div class="form__group">
<div>
<form>
<div class="login__container">
<div class="login__wrapper">
<div>
<div>
<div class="login__form__elements">
<div>
<div>
<h2 class="">Sign In</h2></div>
</div>
<div>
<div>
<div>
<label for="email" id="email-label" class="label__default label__strong label__double-margin">Email</label>
<div>
<input type="text" autocomplete="off" class="input__default form-control" id="email" name="email" aria-invalid="false" aria-describedby="email-error" value="">
</div>
<div id="email-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div>
<div>
<label for="password" id="password-label">Password</label>
<div>
<input type="password" autocomplete="off" id="password" name="password" aria-invalid="false" aria-describedby="password-error" value="">
</div>
<div id="password-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div><a to="/">Forgotten your password?</a></div>
<div>
<button type="submit">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer>
<div>
<div>
<div>
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
</body>
When it comes to centering something both vertically and horizontally I like to use css flex. Adding it to the parent container surrounding the element you wish to center will cause it to flex in all screen dimensions and heights. Justify-content centers it horizontally and align-items centers it vertically. Here is a helpful guide to learn more about flex:https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.parent-container{
width:100vw;
height:100vh;
background-color:black;
display:flex;
justify-content:center;
align-items:center;
}
.child{
width:50%;
background-color:white;
text-align:center;
}
<div class="parent-container">
<div class="child">
<h1>Centered</h1>
</div><!-- child -->
</div><!-- parent-container -->
Flexbox and grid work great for this, the difference being that grid is said to be 2 dimensional whereas flexbox is 1 dimensional. See MDN's Relationship of flexbox to other layout methods. BTW: If you want a sticky footer add min-height: 100vh; to your container.
Both Ron and Jeh's answer are correct. Though I'm wondering why do you have so many container wrappers then if you can just use certain wrappers to display your entire login form, banner and footer.
Here's my template for my custom login forms.
You will noticed that I use calc on height to differentiate the height of banner and footer and then less it to the height of your .section-login container, in which it will automatically adjusted the height no matter what the browser height does. And I declared min-height just to avoid overlaying above to each container wrapper.
Hope this helps.
.login {
background: pink;
margin: 0;
padding: 0;
}
.body-wrapper {
background: white;
width: 100%;
height: 100vh;
}
.hero-wrapper,
.globalfooter {
background: #CCC;
text-align: center;
}
.hero-wrapper {
line-height: 200px; /* just for the text v-alignment only */
height: 200px;
}
.globalfooter {
line-height: 100px; /* just for the text v-alignment only */
height: 100px;
}
.section-login {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #EEE;
min-height: calc(100% - (200px + 100px));
padding: 30px;
box-sizing: border-box;
}
.help-text-wrapper {
font: 300 12px sans-serif;
color: red;
text-align: center;
margin: 15px 0 0;
}
.help-text-wrapper.hidden {
/* Remove comment to enable
display: none; */
}
h1 {
font: 600 24px sans-serif;
text-align: center;
text-transform: uppercase;
margin: 0 0 15px;
}
form {
background: #FFF;
font: 300 12px sans-serif;
text-transform: uppercase;
width: 260px;
padding: 30px;
box-shadow: 0 0 5px 0 rgba(0,0,0,0.50);
box-sizing: border-box;
border-radius: 3px;
}
form > fieldset {
margin: 0 0 15px;
padding: 0;
border: 0;
}
form > fieldset label:first-child {
display: block;
margin-bottom: 15px;
}
form input {
display: block;
width: 100%;
height: 30px;
margin: 5px 0;
padding: 6px;
box-sizing: border-box;
}
form button {
display: block;
background: #888;
color: #FFF;
text-transform: uppercase;
height: 30px;
margin: auto;
padding: 7px 15px;
border: 0;
cursor: pointer;
}
<body class="login page">
<div class="body-wrapper">
<header class="hero-wrapper">
Banner
</header>
<section class="section-login">
<h1>Sign In</h1>
<form action="" method="post">
<fieldset>
<label for="username">
Username
<input type="text" id="username" value="" placeholder="Username" autofocus>
</label>
<label for="password">
Password
<input type="password" id="password" value="" placeholder="Password">
</label>
</fieldset>
<button type="submit">Login / Sign In</button>
</form>
<div class="help-text-wrapper hidden">
Something around here after fallback.
</div>
</section>
<footer class="globalfooter">
Footer
</footer>
</div>
</body>
Just change some class properties which I wrote down:
.login-layout__positioner {
display: flex;
align-items: center;
justify-content: center;
}
.form__group {
background-color: transparent;
}
a {
color: #333;
}
footer a {
color: #fff;
}

Make a div non-scroll able

I have two div in side a row named sidenav and mainscreen. I have assigned sidenav 1 column and mainscreen 11 columns by bootstrap. Floowing is the output of the following.
I want to make sidenav non scrollable but mainscreen should be srollable. Many solutions suggest using position:fixed. I tried making the position of sidenav fixed but it ruins the style of whole page. Following is the output after using fixed position of sidenav.
following is html!
<div class="container-fluid" style="width: 100%; padding: 0">
<div class="row" style="width: 100%;margin: 0px">
<nav class="sidenav col-md-1">
<ul class="menu">
<li class="menu-item">
<img src="../../assets/images/Mask Group 7.svg" alt="Logo" width="75"height="75">
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/home.svg" alt="Home" width="100%" height="100%">
<span class="navtext">home</span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/accept-file-or-checklist.svg" alt="Home" width="100%" height="100%">
<span class="navtext">approval </span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/folded-text-document.svg" alt="Home" width="100%" height="100%">
<span class="navtext">document</span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/wukla_logo.svg" alt="Home" width="100%" height="100%">
<span class="navtext">wukla</span>
</a>
</li>
</ul>
</nav>
<div class="mainscreen col-md-11">
<div class="header">
<div class="inputs">
<div class="input-group">
<span class="input-group-btn" style="height:45px">
<button class="searchinputbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">hate</button>
</span>
<input type="text" class="form-control" placeholder="Product name" style="border-style: none">
<span class="input-group-btn">
<button class="searchinputbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">love</button>
</span>
</div>
<button class="uploadbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">Upload Document</button>
</div>
</div>
<div class="mainbody">
<div class="itemstodisplay">
<div class="notification">
<div class="bodytext">pending signatures</div>
<div class="components">
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
</div>
</div>
<div class="alldocs">
<div class="bodytext">all documents</div>
<div class="components">
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
</div>
</div>
<div class="wukladocs">
<div class="bodytext">wukla documents</div>
<div class="components">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
and following is scss!
#ID {
overflow: hidden
}
.sidenav {
position: fixed;
padding: 0;
background-color: #e6e6e6 ;
display: flex;
flex-direction: column;
justify-content: flex-start;
height: auto;
}
.menu {
padding: 0px;
list-style: none;
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
}
.menu-item {
border-bottom: 1px solid #ffffff;
height: 10%;
display: flex;
flex-direction: column;
width: 100%;
justify-content: center;
align-items: center;
}
.mainscreen {
padding: 0;
height: 1450px;
}
.header {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
//width: 1259px;
width: 100%;
height: 36%;
opacity: 0.58;
background-color: #8cd1bc;
}
.mainbody {
height: 64%;
background-color: #f6f6f6;
}
.input-group{
width: 100%;
}
.searchinputbtn {
height: 20px;
}
.uploadbtn {
margin-top: 42px;
padding-left: 30px;
padding-right: 30px;
border-radius: 2px;
background-color: #e6e6e6;
font-size: 16.8px;
font-weight: bold;
letter-spacing: -0.3px;
text-align: left;
color: #ffffff
}
.inputs {
width: 35%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.navtext {
font-size: 11px;
line-height: 0.95;
letter-spacing: -0.3px;
text-align: left;
color: #59626a;
}
.itemstodisplay {
width: 100%;
height: 100%;
}
.notification {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 26%;
background-color: azure;
}
.bodytext{
margin-bottom: 20px;
margin-top: 50px;
font-size: 20px;
line-height: 0.53;
letter-spacing: -0.5px;
text-align: left;
color: #73c7af;
}
.alldocs{
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 38%;
background-color: cornsilk;
}
.wukladocs {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 38%;
background-color:floralwhite;
}
.components {
height: 80%;
width: 100%;
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: center;
}
can anybody help me making sidenav non-scroll able?
You can use position: fixed and stretch the div to the length of the whole page. This can be done with the following CSS:
div {
position: fixed;
top: 0;
bottom: 0;
}
Then you can make the mainscreen scrollable and keep the sidenav fixed.
Try this:
.navbar-fixed-left {
width: 140px;
position: fixed;
border-radius: 0;
height: 100%;
}
.navbar-fixed-left .navbar-nav > li {
float: none; /* Cancel default li float: left */
width: 139px;
}
refer this article for more:
Usefull Article