How to use transform to align legend in HTML? - html

I have created a discrete legend using HTML, but I am struggling with trying to get the legend title to align correctly, irrespective of the length of the text within the title.
Here is an example of what it looks like in my app for a short title
... whereas this is what it is like for a longer title
Below is an attempt at a minimal working example
/* Split the screen in half */
.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
/* Control the left side */
.left {
left: 0;
}
/* Control the right side */
.right {
right: 0;
background-color: #999;
}
.box{
background-color: black;
height: 100%;
width: 100%;
}
.my-legend .legend-title {
text-align: center;
margin-bottom: 5px;
font-weight: bold;
font-size: 30px;
color: red;
}
.my-legend .legend-scale ul {
margin: 0;
margin-bottom: 5px;
padding: 0;
float: left;
list-style: none;
}
.my-legend .legend-scale ul li {
text-align: right;
list-style: none;
margin-left: 0;
line-height: 18px;
margin-bottom: 2px;
color: white;
font-size: 20px;
padding-bottom: 40px;
}
.my-legend ul.legend-labels li span {
display: block;
float: right;
height: 45px;
width: 20px;
margin-right: 0px;
margin-left: 5px;
border: 1px solid #999;
}
<div class="row" id="content">
<!-- Image Panel -->
<div class="split left" style="position: relative; height: 800px">
<!-- This is a dynamically generated panel ... but just black here as example -->
<div id="imagePanel" class="box"></div>
<!-- Legend entries -->
<div class='my-legend'
style="position:absolute;
right: 10%; top: 50%;
transform-box: fill-box;
transform: translate(0%,-50%);">
<div class='legend-scale'>
<ul class='legend-labels'>
<li> <b>0</b> <span style="background: rgb(128,64,0)"> </span> </li>
<li> <b>1</b> <span style="background: rgb(251,255,128)"></span> </li>
<li> <b>2</b> <span style="background: rgb(55,128,0)"> </span> </li>
<li> <b>3</b> <span style="background: rgb(128,255,140)"></span> </li>
<li> <b>4</b> <span style="background: rgb(0,128,81)"> </span> </li>
<li> <b>5</b> <span style="background: rgb(128,234,255)"></span> </li>
<li> <b>6</b> <span style="background: rgb(0,38,128)"> </span> </li>
<li> <b>7</b> <span style="background: rgb(157,128,255)"></span> </li>
<li> <b>8</b> <span style="background: rgb(98,0,128)"> </span> </li>
<li> <b>9</b> <span style="background: rgb(255,128,217)"></span> </li>
</ul>
</div>
</div>
<!-- Legend Title -->
<div class='my-legend'
style="position:absolute;
right: 0; top: 50%;
transform-box: fill-box;
transform: translate(0%,-50%);
transform: rotate(-90deg)">
<div class='legend-title' >True Label</div>
</div>
</div>
<!-- Controls -->
<div class="split right" id="controlsPanel" >
Some Other Panel will go here
</div>
</div>

writing-mode should sidestep the width/height headache caused by rotating, but I can't find a way to avoid having to rotate by 180 to flip it the way you want.
Edit: Replaced absolute/relative positioning with grid, positioned legend text without overlay.
/* Split the screen in half */
body {
margin: 0;
}
.row {
display: grid;
grid-template-columns: 50% 50%;
}
.left {
display: grid;
grid-template-columns: 4fr min-content 1fr;
background-color: black;
}
.right {
background-color: #999;
}
.legend-title {
max-height: 40ch;
writing-mode: vertical-rl;
transform: rotate(180deg);
text-align: center;
font-weight: bold;
font-size: 2rem;
color: red;
}
.my-legend .legend-scale ul {
margin: 0;
margin-bottom: 5px;
padding: 0;
float: left;
list-style: none;
}
.my-legend .legend-scale ul li {
text-align: right;
list-style: none;
margin-left: 0;
line-height: 18px;
margin-bottom: 2px;
color: white;
font-size: 20px;
padding-bottom: 40px;
}
.my-legend ul.legend-labels li span {
display: block;
float: right;
height: 45px;
width: 20px;
margin-right: 0px;
margin-left: 5px;
border: 1px solid #999;
}
<div class="row" id="content">
<!-- Image Panel -->
<div class="split left">
<!-- This is a dynamically generated panel ... but just black here as example -->
<div id="imagePanel" class="box"></div>
<!-- Legend entries -->
<div class='my-legend'>
<div class='legend-scale'>
<ul class='legend-labels'>
<li><b>0</b> <span style="background: rgb(128,64,0)"></span></li>
<li><b>1</b> <span style="background: rgb(251,255,128)"></span></li>
<li><b>2</b> <span style="background: rgb(55,128,0)"></span></li>
<li><b>3</b> <span style="background: rgb(128,255,140)"></span></li>
<li><b>4</b> <span style="background: rgb(0,128,81)"></span></li>
<li><b>5</b> <span style="background: rgb(128,234,255)"></span></li>
<li><b>6</b> <span style="background: rgb(0,38,128)"></span></li>
<li><b>7</b> <span style="background: rgb(157,128,255)"></span></li>
<li><b>8</b> <span style="background: rgb(98,0,128)"></span></li>
<li><b>9</b> <span style="background: rgb(255,128,217)"></span> </li>
</ul>
</div>
</div>
<!-- Legend Title -->
<div class='legend-title'>True Label test test test test test test test test test test test test test test test test test test test</div>
</div>
<!-- Controls -->
<div id="controlsPanel" class="split right">
Some Other Panel will go here
</div>
</div>

Related

5th Container in a grid is not following alignment as the others - why?

I've been creating this one page, using containers and grids to have each row separate for reasons only the requester knows. What I'm sitting with at the moment, is that the first 4 containers align perfectly but the minute I try to add the 5th container, it sits to the right, and directly on top of the 4th container.
I've had to add quite a few <br> in order to get it to sit below the 4th container and as you can see on this codepen: https://codepen.io/nyxerian/pen/wvoPMoz , the first 4 containers are at a margin-left:255px;but the 5th container doesn't even have that property, and I've had to reduce the length of the container itself so that it doesn't scroll off to the right. Where its sitting now seems to be the 'start' of the page and I do not understand why.
I've added my code below and any insight as to how I can align them, and what the actual issue is would be most helpful.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="appOutcome.css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://use.fontawesome.com/releases/v5.15.2/js/all.js"></script>
</head>
<body>
<!-- start: SIDEBAR NAV AND HEADER -->
<div class='fixed header'>
<i class="far fa-bell" style="float: right; height: 35px; width: 35px; margin-top: 25px; margin-right: 80px; color: white;"></i>
<i class="far fa-comments" style="float: right; height: 35px; width: 35px; margin-top: 25px; margin-right: 20px; color: white;"></i>
</div>
<div class='fixed side'>
<img class="smartlogo" src="PNG1.png" alt="smart">
<nav class="sidebar">
<div class="text"></div>
<br>
<ul>
<li class="active"><i class="fas fa-home" style="color:#2DAAD6;"></i>   Home</li>
<li><i class="far fa-handshake fa-fw" style="color: #2DAAD6;"></i>   Sell</li>
<li><i class="fas fa-chart-line" style="color: #2DAAD6;"></i>   Dashboards</li>
<li><i class="fas fa-boxes" style="color: #2DAAD6;"></i>   Inventory</li>
<li><i class="far fa-credit-card" style="color: #2DAAD6;"></i>   Payments</li>
<li>
<i class="far fa-folder-open" style="color: #2DAAD6;"></i>   Leads
<ul class="lead-show">
<li>Referrals</li>
<li></i>Management</li>
<li>Settings</li>
</ul>
</li>
<li><i class="fas fa-users" style="color: #2DAAD6;"></i>   Teams</li>
<li><i class="far fa-clipboard" style="color: #2DAAD6; margin-left: 7px;"></i>   Reporting</li>
<li><i class="fas fa-tools" style="color: #2DAAD6;"></i>   Settings</li>
</ul>
</nav>
</div>
<div class='scrollable'></div>
<!-- start: Bubble header -->
<div class="bubbleBar1">
<img class="bubbleBar1" src="/Leads/3. Leads Management - Qualifications/Qualifications - Appointment Outcome/bubbleBar2.1.png">
<br>
</div>
<div class="bubbleHeadings">
<div class="wrapper">
<div class="box">
<p>Qualifications</p>
</div>
<div class="box">
<p>Working</p>
</div>
<div class="box">
<p>Converted</p>
</div>
</div>
</div>
<!-- start: content -->
<br><br>
<form> <div class="refInfo">
<div class="wrapper2">
<div class="box1">
<p style="width: 150px;">Name & Surname</p>
<input type="text" class="fullName">
</div>
<div class="box2">
<p>Number</p>
<input type="text" class="mobileNum">
</div>
<div class="box3">
<p>Suburb</p>
<input type="text" class="suburb">
</div>
<div class="box4">
<p>City</p>
<input type="text" class="city">
</div>
</div>
</div>
<div class="outcomeInfo">
<div class="wrapper3">
<div class="box5">
<p>Date Contacted</p>
<input>
</div>
<div class="box6">
<p>Call Outcome</p>
<input>
</div>
<div class="box7">
<p>Comments</p>
<textarea name="commentNotes" id="commentNotes" rows="3" cols="30"></textarea>
</div>
</div>
</div>
</form>
<br>
<form>
<div class="appInfo">
<div class="wrapper4">
<div class="box8">
<p>Appointment Date</p>
<input type="date" class="appDate" style="width: 160px;">
</div>
<div class="box9">
<p>Time</p>
<input type="time" class="appTime" style="width: 160px;">
</div>
<div class="box10">
<p>Address</p>
<textarea name="address" id="address" rows="3" cols="30"></textarea>
</div>
<div class="box">
</div>
</div>
</form>
<br>
<form>
<br><br><br><br><br><br> <!-- Mass breaks to get it below the 4th container -->
<div class="appResult">
<div class="wrapper5">
<div class="box11">
<p>Appointment Result</p>
<select name="appOutcome" id="appOutcome" style="width: 165px; height: 24px;">
<option value="select">Select an Option</option>
<option value="purchase">Purchase</option>
<option value="reschedule">Reschedule Appointment</option>
<option value="notInterested">Not Interested</option>
</select>
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box12">
<div class="updateBtn">
<div class="updateBtn">
<button class="updateBtn">Update</button>
</div>
</div>
</form>
<script>
$('.lead-btn').click(function () {
$('nav ul .lead-show').toggleClass('show')
$('nav ul .first').toggleClass('rotate')
})
$('nav ul li').click(function () {
$(this).addClass('active').siblings().removeClass('active')
})
</script>
</body>
</html>
CSS
#import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
* {
margin: 0;
padding: 0;
user-select: none;
box-sizing: border-box;
font-family: 'nordstern', Helvetica;
}
/* ENSURING SCOLLABLE PAGE */
.scrollable {
width: 100%;
margin: 100px auto;
}
.fixed {
position: fixed;
}
/*HEADER AND SIDEBAR */
.header {
top: 0;
left: 0;
right: 0;
height: 80px;
background-image: linear-gradient(
to right,
#436c89,
#6ca1cd,
#60b9c0
) !important;
}
.smartlogo {
width: 140px;
height: 45px;
margin-left: 40px;
margin-top: 28px;
}
.side {
top: 0;
left: 0;
bottom: 0;
width: 240px;
background-color: #e7e6e6;
}
.sidebar {
height: 80%;
width: 240px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #e7e6e6;
margin-top: 85px;
}
.sidebar.show {
left: 0px;
}
.sidebar .text {
color: black;
font-size: 25px;
font-weight: 600;
line-height: 65px;
text-align: center;
justify-content: left;
background: #e7e6e6;
letter-spacing: 1px;
font-family: nordstern
}
nav ul {
background: #e7e6e6;
height: 100%;
width: 100%;
list-style: none;
}
nav ul li {
line-height: 60px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
nav ul li:last-child {
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
nav ul li a {
position: relative;
color: black;
text-decoration: none;
font-size: 18px;
padding-left: 40px;
font-weight: 500;
display: block;
width: 100%;
border-left: 3px solid transparent;
}
nav ul li.active a {
color: black;
background: #e7e6e6;
border-left-color: #60b9c0;
}
nav ul li a:hover {
background: #ffffff;
}
nav ul ul {
position: static;
display: none;
}
nav ul .lead-show.show {
display: block;
}
nav ul .serv-show.show1 {
display: block;
}
nav ul ul li {
line-height: 42px;
border-top: none;
}
nav ul ul li a {
font-size: 17px;
color: #e6e6e6;
padding-left: 80px;
}
nav ul li.active ul li a {
color: Black;
background: #e7e6e6;
border-left-color: transparent;
}
nav ul ul li a:hover {
color: black !important;
background: #ffffff !important;
}
nav ul li a span {
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
font-size: 22px;
transition: transform 0.4s;
}
nav ul li a span.rotate {
transform: translateY(-50%) rotate(-180deg);
}
/* BUBBLEBAR IMAGE STYLE */
.bubbleBar1 {
margin-left: 200px;
}
/* BUBBLE WORDING */
.bubbleHeadings {
margin-left: 255px;
display: flex;
justify-content: left;
width: 1250px;
height: 35px;
align-items: baseline;
background: white;
}
.wrapper {
width: 180px;
margin-left: 170px;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap:355px
}
/*----------------------Referral Information container-----------------------------------*/
.refInfo {
margin-left: 255px;
display: flex;
justify-content: left;
width: 1260px;
height: 120px;
align-items: baseline;
background: #F2F2F2;
}
.wrapper2 {
margin-top: 30px;
width: 150px;
margin-left: 20px;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 150px;
}
/*-----------------------Call Outcome container------------------------------------------*/
.outcomeInfo {
margin-left: 255px;
display: flex;
justify-content: left;
width: 1260px;
height: 120px;
align-items: baseline;
background: #F2F2F2;
}
.wrapper3 {
margin-top: 30px;
width: 150px;
margin-left: 20px;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 150px;
}
/*----------------------Appointment Date Container------------------------------------------*/
.appInfo {
margin-left: 255px;
display: flex;
justify-content: left;
width: 1260px;
height: 120px;
align-items: baseline;
background: #F2F2F2;
}
.wrapper4 {
margin-top: 30px;
width: 150px;
margin-left: 20px;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 150px;
}
/*-----------------------Appointment Result Container------------------------------------------*/
.appResult {
display: flex;
justify-content: left;
width: 1090px;
height: 120px;
align-items: baseline;
background: #F2F2F2;
}
.wrapper5 {
margin-top: 30px;
width: 150px;
margin-left: 20px;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 150px;
}
/* Enter and update Button Styling */
.updateBtn {
float: right;
margin-left: 50px;
width: 150px;
border-radius: 15px;
height: 35px;
border: none;
color: white;
background-color: #2DAAD6;
}
.updateBtn button:hover {
background-color: #60b9c0;
}
.box12 {
margin-left: 195px;
}
I think your problem comes from the fact that HTML hierarchy has an impact on which element relates to which element as a container or as an item.
In your case what you have commented as being the "5th container" in your CSS (.appResult) is child of a form element, which itself is child of appInfo.
So appInfo has a display: flex; with default row direction. It is thus normal that its 2 children (.wrapper4 and the form that holds .appResult) are next to each other horizontally.
What you call your containers are placed in the HTML hierarchy so that they are not next to each other, they are separated by other parent elements, they do not relate to each other through a grid display.
To have your "5th container" below instead of on the right, you can change the direction of the flex container that is its parent:
.appInfo {
flex-direction: column;
}
Or you have to rethink deeply your HTML hierarchy.

Multiple Images in an input box (Google Searchbar)

I am fairly new to coding. I am working on recreating the Google home page for The Odin Project and I cannot seem to get the images to sit right in the search bar.
Thus far all of my code and formatting has been done in HTML. I was struggling how to do CSS and push it via Git. anyway...
I got the magnifying glass to sit in the proper spot, but when I went to add the microphone image, it overlaps the magnifying glass. The code is as follows:
<!DOCTYPE html>
<html lang="en">
<style>
<!--FONTS-->
#import url('https://fonts.googleapis.com/css2?family=Manrope&display=swap');
body{
overflow-x: hidden !important;
max-width: 90%;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 350px;
}
button {
width: 127px;
height: 36px;
text-align: center;
border: none;
background-color: #f2f2f2;
border-radius: 5px;
font-size: 13px;
color: #777;
font-family: 'Manrope', sans-serif;
}
input {
border-width: 3px;
border-color: #f2f2f2;
display: block;
margin-left: auto;
margin-right: auto;
width: 400px;
height: 37px;
text-align: center;
font-size: 20px;
border-radius: 50px;
border-style: solid;
font-family: 'Manrope', sans-serif;
}
.btn-toolbar {
display: flex;
flex-direction: row;
justify-content: center;
}
.btn-toolbar button:hover {
background-color: #88888888;
}
ul {
background-color: #f2f2f2;
float: left;
width: 100%;
display: inline-block;
}
a {
color: #777;
display: inline-block;
font-size: 15px;
text-decoration: none;
}
a:hover {
color: green;
}
.column {
float: left;
}
.footer{
position:absolute;
bottom: 0;
width: 100%;
font-family: 'Manrope', sans-serif;
}
.header{
position:absolute;
top: 0;
width: 100%;
font-family: 'Manrope', sans-serif;
}
h1{
display: flex;
justify-content: center;
align-items: center;
}
.fake-input{
position: relative;
width: 350px;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
}
.fake-input input{
background-color: #fff;
display: block;
width:100%;
box-sizing: border-box;
}
.fake-input img{
position: absolute;
top: 11px;
left: 10px;
}
</style>
<div class="row">
<header id="header" class="header">
<ul style="list-style-type:none;">
<li>
<a class="column" href="https://www.google.com">About</a>
<a class="column" href="https://www.google.com">Store</a>
<a class="column" href="https://www.google.com">images</a>
<a class="column" href="https://www.google.com">gmail</a>
<a class="column" href="https://www.google.com">squares</a>
<a class="column" href="https://www.google.com">circle</a>
</li>
</ul>
</header>
<body>
</div>
<!-- Google Logo -->
<div>
<h1><img style="padding-bottom: 20px; padding-top: 60px;" class="center" id="google-image" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</h1>
</div>
<div>
<!--Google search bar -->
<!-- Search input text -->
<div class="fake-input">
<input type="text" placeholder="Search Google or type URL" />
<img id="msgnify" src="https://cdn.pixabay.com/photo/2017/01/13/01/22/magnifying-glass-1976105_1280.png" width=15 />
<img id="mic" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/833px-Google_mic.svg.png" width=15>
</div>
<br>
<!-- Search Buttons -->
<div style="padding-top: 20px;" class="btn-toolbar">
<button>Google Search</button>
<button>I'm Feeling Lucky</button>
</div>
</div>
<br>
</body>
<!-- footer contains link to the respective locations -->
<div class="row">
<footer id="footer" class="footer">
<ul style="list-style-type:none;">
<li>
<a class="column" href="https://www.google.com">Advertising</a>
<a class="column" href="https://www.google.com">Business</a>
<a class="column" href="https://www.google.com">How Search Works</a>
<a class="column" href="https://www.google.com">Privacy</a>
<a class="column" href="https://www.google.com">Terms</a>
<a class="column" href="https://www.google.com">Settings</a>
</li>
</ul>
</footer>
</div>
</html>
I tried changing the class, giving it an id, setting the position to relative and margin right as auto, but i cannot seem to get it to move over to the right side of the search bar.
Additionally, the buttons below the search bar are stuck together. I had each button as its own, but the moment I added them to the same div they have become ajoined and when I try to separate them, the only way i can get them on them aligned is by styling them to the same row. Margin does not help split them apart, I even tried to get them in separate columns no dice. I am really frustrated as i made it pretty far in a day just using HTML. I would like to keep it HTML until I learn how to push CSS to GitHub via Git.
Thank you in advance!!!
You've set the fake-input to position: relative and the image to position: absolute which is already correct, but for the img#mic you need to set it's position right and not left to make it appear in the right side of the fake-input, so I add some style like this
.fake-input img#mic{
position: absolute;
left: unset;
right: 10px;
}
And for the button, it's working if you add the margin for the button like in the updated snippet below
<!DOCTYPE html>
<html lang="en">
<style>
<!--FONTS-->
#import url('https://fonts.googleapis.com/css2?family=Manrope&display=swap');
body{
overflow-x: hidden !important;
max-width: 90%;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 350px;
}
button {
width: 127px;
height: 36px;
text-align: center;
border: none;
background-color: #f2f2f2;
border-radius: 5px;
font-size: 13px;
color: #777;
font-family: 'Manrope', sans-serif;
margin: 10px;
}
input {
border-width: 3px;
border-color: #f2f2f2;
display: block;
margin-left: auto;
margin-right: auto;
width: 400px;
height: 37px;
text-align: center;
font-size: 20px;
border-radius: 50px;
border-style: solid;
font-family: 'Manrope', sans-serif;
}
.btn-toolbar {
display: flex;
flex-direction: row;
justify-content: center;
}
.btn-toolbar button:hover {
background-color: #88888888;
}
ul {
background-color: #f2f2f2;
float: left;
width: 100%;
display: inline-block;
}
a {
color: #777;
display: inline-block;
font-size: 15px;
text-decoration: none;
}
a:hover {
color: green;
}
.column {
float: left;
}
.footer{
position:absolute;
bottom: 0;
width: 100%;
font-family: 'Manrope', sans-serif;
}
.header{
position:absolute;
top: 0;
width: 100%;
font-family: 'Manrope', sans-serif;
}
h1{
display: flex;
justify-content: center;
align-items: center;
}
.fake-input{
position: relative;
width: 350px;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
}
.fake-input input{
background-color: #fff;
display: block;
width:100%;
box-sizing: border-box;
}
.fake-input img{
position: absolute;
top: 11px;
left: 10px;
}
.fake-input img#mic{
position: absolute;
left: unset;
right: 10px;
}
</style>
<div class="row">
<header id="header" class="header">
<ul style="list-style-type:none;">
<li>
<a class="column" href="https://www.google.com">About</a>
<a class="column" href="https://www.google.com">Store</a>
<a class="column" href="https://www.google.com">images</a>
<a class="column" href="https://www.google.com">gmail</a>
<a class="column" href="https://www.google.com">squares</a>
<a class="column" href="https://www.google.com">circle</a>
</li>
</ul>
</header>
<body>
</div>
<!-- Google Logo -->
<div>
<h1><img style="padding-bottom: 20px; padding-top: 60px;" class="center" id="google-image" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</h1>
</div>
<div>
<!--Google search bar -->
<!-- Search input text -->
<div class="fake-input">
<input type="text" placeholder="Search Google or type URL" />
<img id="msgnify" src="https://cdn.pixabay.com/photo/2017/01/13/01/22/magnifying-glass-1976105_1280.png" width=15 />
<img id="mic" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/833px-Google_mic.svg.png" width=15>
</div>
<br>
<!-- Search Buttons -->
<div style="padding-top: 20px;" class="btn-toolbar">
<button>Google Search</button>
<button>I'm Feeling Lucky</button>
</div>
</div>
<br>
</body>
<!-- footer contains link to the respective locations -->
<div class="row">
<footer id="footer" class="footer">
<ul style="list-style-type:none;">
<li>
<a class="column" href="https://www.google.com">Advertising</a>
<a class="column" href="https://www.google.com">Business</a>
<a class="column" href="https://www.google.com">How Search Works</a>
<a class="column" href="https://www.google.com">Privacy</a>
<a class="column" href="https://www.google.com">Terms</a>
<a class="column" href="https://www.google.com">Settings</a>
</li>
</ul>
</footer>
</div>
</html>
you should give position :relative to class (fake-input);
then give position :absolute to (search.png or mic.

On hover, text appears on top of header

I'm new to .html, self taught, finishing up a website but I'm having some issues with my header.
I have some text that scales on hover, but if part of the text is obscured by the header the text will scale and appear on top of the header, how do I fix this?
I've included a snippet to show what I mean.
/************************** Header *******************/
header {
min-height: 150px;
background: #ccc;
position: fixed;
width: 100%;
}
header ul{
display: inline;
text-align: left;
}
header ul li{
margin-left: 0px;
padding: 2px;
}
header ul li:first-child{
margin-left: 0px;
padding: 2px;
}
header ul li:last-child{
margin-bottom: 30px;
padding: 2px;
}
.spacer{
height: 150px;
}
/********************* Table & Buttons ******************/
.select{
height: 100%;
background-color: #f2f2f2;
padding-top: 35px;
padding-bottom: 35px;
}
.category {
margin: 0 auto;
width: 90%;
border-collapse: collapse;
height: 10%;
background-color: #f2f2f2;
text-align: center;
font-size: xx-large;
}
.mb, .ce{
width: 50%;
}
.mb{
border-right: 2px solid #2F4858;
}
.mb:hover, .ce:hover{
transform: scale(1.1);
transition: transform .2s;
}
.sub{
text-align: center;
font-size: x-large;
width: 100%;
}
.btn {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
}
.spacer2 {
height: 140px;
background: #f2f2f2;
}
<header>
<nav>
<ul>
<li>
<a>Home</a>
</li>
<li class="current">
Portfolio
</li>
<li>
<a>About</a>
</li>
<li>
<a>Contact / Services</a>
</li>
</ul>
</nav>
</header>
<section class="spacer">
</section>
<seciton>
<div class="sub">
<p> Links </p>
</div>
<div class="select">
<table class="category">
<tr>
<td class="mb" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number One</p>
</button>
</td>
<td class="ce" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number Two</p>
</button>
</td>
</tr>
</table>
</div>
</seciton>
<section class="spacer2">
</section>
Using z-index on your header and yours section (be carefull you have wrote seciton one time) did the trick:
/************************** Header *******************/
header {
min-height: 150px;
background: #ccc;
position: fixed;
width: 100%;
z-index: 1; /* ---Set a z-index here--- */
}
header ul{
display: inline;
text-align: left;
}
header ul li{
margin-left: 0px;
padding: 2px;
}
header ul li:first-child{
margin-left: 0px;
padding: 2px;
}
header ul li:last-child{
margin-bottom: 30px;
padding: 2px;
}
.spacer{
height: 150px;
}
/********************* Table & Buttons ******************/
.select{
height: 100%;
background-color: #f2f2f2;
padding-top: 35px;
padding-bottom: 35px;
}
.category {
margin: 0 auto;
width: 90%;
border-collapse: collapse;
height: 10%;
background-color: #f2f2f2;
text-align: center;
font-size: xx-large;
}
.mb, .ce{
width: 50%;
}
.mb{
border-right: 2px solid #2F4858;
}
section {
z-index: 0; /* ---And another here that is lower--- */
}
.mb:hover, .ce:hover{
transform: scale(1.1);
transition: transform .2s;
z-index: 0;
}
.sub{
text-align: center;
font-size: x-large;
width: 100%;
}
.btn {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
}
.spacer2 {
height: 140px;
background: #f2f2f2;
}
<header>
<nav>
<ul>
<li>
<a>Home</a>
</li>
<li class="current">
Portfolio
</li>
<li>
<a>About</a>
</li>
<li>
<a>Contact / Services</a>
</li>
</ul>
</nav>
</header>
<section class="spacer">
</section>
<section>
<div class="sub">
<p> Links </p>
</div>
<div class="select">
<table class="category">
<tr>
<td class="mb" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number One</p>
</button>
</td>
<td class="ce" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number Two</p>
</button>
</td>
</tr>
</table>
</div>
</section>
<section class="spacer2">
</section>
⚠️I really recommand you to wrap all your content that is not in the header in a <main></main> component to easily write this type of cleaner css rules:
header {
z-index: 1;
}
main{
z-index: 0;
}

Center text on bottom of the div container

Could someone explain me how do I center my text on bottom of the div container?
<div class="container-fluid">
<header id="welcome-header" class="row">
<div id="welcome-div">
<img src="img/logo.png" alt="logo">
<h1 class="welcome-text">
<span>Hi, I'm Robert. I design & build</span>
<br>
<span class="welcome-text-animation"></span>
</h1>
<div class="hire-button">
Yes, I'm available for hire
</div>
<div class="page-scroll ">
<a href="#welcome-div">
Learn more about what i do
<br>
<i class="fa fa-chevron-down"></i>
</a>
</div>
</div>
</header>
Im trying to get "Learn more about what i do" at the bottom of "welcome-header" row.
CSS :
#welcome-div {
min-height: 100%;
position: relative;
}
.page-scroll {
}
.page-scroll a {
font-family: Sansita;
text-decoration: none;
font-size: 20px;
color: aliceblue;
}
Sorry guys u get me wrong. I want the string to stick to bottom like bottom: 0px;
http://codepen.io/anon/pen/jBLaBX
Add position: relative to #welcome-header then position: absolute; bottom: 0; left: 0; right: 0 to .page-scroll to position the element at the bottom of #welcome-header, and your text-align: center rule will center the text horizontally.
#import url('https://fonts.googleapis.com/css?family=Sansita');
#welcome-header {
width: 100%;
height: 100vh;
background-image: url(img/background.jpg);
position: relative;
}
.welcome-text,
.welcome-text-animation {
font-family: Sansita;
text-align: center;
color: aliceblue;
font-size: 50px;
padding-top: 90px;
}
.home-logo {
display: block;
text-align: center;
}
.home-logo img {
display: inline-block;
padding: 2.5%;
width: 120px;
height: 120px;
margin-left: auto;
margin-right: auto;
display: block;
}
.hire-button {
text-align: center;
padding-top: 90px;
}
.hire-button a {
font-family: Sansita;
text-decoration: none;
color: aliceblue;
font-size: 25px;
border: 2px solid #FDCD3B;
border-radius: 50px;
padding: 1.2%;
transition: all 0.2s linear;
}
.hire-button a:hover {
background-color: #FDCD3B;
color: #2A3A3F;
padding-left: 3%;
padding-right: 3%;
}
#welcome-div {}
.page-scroll {
text-align: center;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
.page-scroll a {
font-family: Sansita;
text-decoration: none;
font-size: 20px;
color: black;
}
<body>
<div class="container-fluid">
<header id="welcome-header" class="row">
<div id="welcome-div">
<img src="img/logo.png" alt="logo">
<h1 class="welcome-text">
<span>Hi, I'm Robert. I design & build</span>
<br>
<span class="welcome-text-animation"></span>
</h1>
<div class="hire-button">
Yes, I'm available for hire
</div>
<div class="page-scroll ">
<a href="#welcome-div">
Learn more about what i do
<br>
<i class="fa fa-chevron-down"></i>
</a>
</div>
</div>
</header>
<section id="about" class="row">
ABOUT CONTENT
</section>
<section id="skills" class="row">
SKILLS CONTENT
</section>
<section id="portfolio" class="row">
PORTFOLIO CONTENT
</section>
<section id="contact" class="row">
CONTACT CONTENT HERE
</section>
</div>
</body>
.page-scroll {
text-align:center;
}

Why is all content on my home page overflowing the body border? [duplicate]

This question already has answers here:
What is a clearfix?
(10 answers)
Closed 7 years ago.
On my home page Kendall_Gregory.html, my body border is ignoring the contents in the body and setting an arbitrary border around the page. It ignores every image that is on the page and the divs around them. The same code works on other pages and i can't figure out why this is the exception.
https://jsfiddle.net/hgaLsaz6/3/
HTML
<div>
<a href="Html/MenuPage.html">
<img id="topMenu" src="http://s4.postimg.org/7636jv04p/menu_Top.png">
</a>
</div>
<img id="headerImage" src="http://s16.postimg.org/uqbzk51yd/Header.png">
<div class ="card">
<div class="no-hover">
<!-- <span class = "caption"> Fade </span> -->
<img class="left Fade" src="http://s16.postimg.org/monr28j6t/Fade_Mag.png">
<!-- hover image -->
</div>
<div class="on-hover">
<a href="Html/Fade.html">
<img class="left Fade" src="http://s21.postimg.org/o0f1chw13/Xenia_Lally_Hover.png">
</a>
</div>
</div>
<!-- GE -->
<div class ="card">
<div class="no-hover">
<!-- <span class = "caption"> GE </span> -->
<img class="whiteOverlay right GE" src="http://s16.postimg.org/6vislrw9x/image.png">
</div>
<div class="on-hover">
<a href="Html/GE.html">
<img class="whiteOverlay right GE" src="http://s21.postimg.org/6yhlwnrs7/GE_hover.png">
</a>
</div>
</div>
<!-- Kaleidoscope -->
<div class ="card">
<div class="no-hover">
<img class="left KALEIDOSCOPE " src="http://s16.postimg.org/5fcc0qzol/KALEIDOSCOPE_Thumb.png">
</div>
<div class="on-hover mt100">
<a href="Html/Pantene.html">
<img class="left KALEIDOSCOPE" src="http://s16.postimg.org/7q5c7t44l/KALEIDOSCOPE_Thumb_hover.png">
</a>
</div>
</div>
<!-- AOHH -->
<div class ="card">
<div class="no-hover">
<img class="right ArtofHealthyHair" src="http://postimg.org/image/n7subiald/">
</div>
<div class="on-hover">
<a href="Html/AOHH.html">
<img class=" right ArtofHealthyHair" src="http://s21.postimg.org/u56jpto4n/Artof_Healthy_Hair_Hover.png">
</a>
</div>
</div>
<!-- Nexxus -->
<div class ="card mt100">
<div class="no-hover mt100">
<img class=" left Nexxus" src="http://s16.postimg.org/e05nrx9ut/Nexxus.png">
</div>
<div class="on-hover mt100">
<a href="Nexxus.html">
<img class="left Nexxus" src="http://s21.postimg.org/g00qo0f3b/Nexxus_Hover.png">
</a>
</div>
</div>
<!-- Covergirl -->
<div class ="card">
<div class="no-hover">
<img class="whiteOverlay right CoverGirl" src="http://s16.postimg.org/lh9ta0t2d/Cover_Girl.png">
</div>
<div class="on-hover">
<a href="Html/CoverGirlByKendallG.html">
<img class="whiteOverlay right CoverGirl" src="http://s21.postimg.org/6n05jwbc7/Cover_Girl_Hover.png">
</a>
</div>
</div>
<!-- PRTR -->
<div class ="card">
<div class="no-hover">
<img class="whiteOverlay left PRTR" src="http://s16.postimg.org/ee6zrityd/PRTR.png">
</div>
<div class="on-hover">
<a href="Html/RTR.html">
<img class="whiteOverlay left PRTR" src="http://s21.postimg.org/edbj2s31j/RTR_Hover.png">
</a>
</div>
</div>
<!-- Pantene -->
<div class ="card">
<div class="no-hover">
<img class="whiteOverlay right Pantnene" src="http://s16.postimg.org/3xqvp6uxx/Pantnene.png">
</div>
<div class="on-hover">
<a href="Html/Pantene.html">
<img class="whiteOverlay right Pantnene" src="http://s16.postimg.org/wia0c5rmt/WIOL_Hover.png">
</a>
</div>
</div>
CSS
body{
margin: 0px;
border: black 10px solid;
font-family: 'brandon_grotesque_regularRg', Arial, sans-serif;
line-height: normal;
}
a{
text-decoration: none;
color: black;
}
#topMenu{
right: 20px;
position: fixed;
letter-spacing: 4px;
z-index: 24;
-webkit-font-feature-settings: "kern";
-moz-font-feature-settings: "kern";
-moz-font-feature-settings: "kern=1";
}
.MenuBar{
text-align: center;
width: 65%;
margin:17 auto;
text-decoration: none;
letter-spacing: 2px;
-webkit-font-feature-settings: "kern";
-moz-font-feature-settings: "kern";
-moz-font-feature-settings: "kern=1";
}
.consocials{
bottom: 40;
margin-left: 70px;
margin-right: 70px;
width: 80%;
text-decoration: none;
}
.consocials:hover{
border-bottom:solid black 2px;
padding-bottom: 20px;
text-decoration: none;
color: black;
}
.socials{
margin-right: 20px;
margin-left: 20px;
color: black;
text-decoration: none;
text-transform: uppercase;
}
.socials:hover{
border-bottom:solid black 2px;
padding-bottom: 15px;
text-decoration: none;
color: black;
}
.socials:active{
text-decoration: none;
color: black;
}
.center{
text-align: center;
margin: 0 auto;
}
.left{
float: left;
margin-left: 70px;
}
.right{
float: right;
margin-right: 70px;
}
.rightNoMargin{
float: right;
}
.bottom{
bottom: 30px;
}
.hide{
display: none;
}
.m0a{
margin: 0 auto;
}
.m10a{
margin: 10 auto;
}
.h100{
height: 100%;
}
.w100{
width: 100%;
}
.w85{
width: 85%;
}
.w50{
width: 50%;
}
.w49{
width: 49%;
}
.w40{
width: 40%;
}
.mb200{
margin-bottom: 200px;
}
.mb100{
margin-bottom: 100px;
}
.pb30{
padding-bottom: 30px;
}
.FloatL{
float: left;
}
.FloatR{
float: right;
}
.tAc{
text-align: center;
}
.iLb{
display: inline-block;
}
.m3{
margin-top: 3px;
}
.h90{
height: 90%;
}
.h850p{
height: 850px;
}
.vA{
vertical-align: center;
height: 100%;
}
.h75{
height: 60%
}
.pl20p{
padding-left: 19%;
}
.pR100px{
padding-right: 75px;
}
.w450{
width: 450px;
}
.absolute{
position: absolute;
}
.relative{
position: relative;
}
.mnh100{
min-height: 100px;
}
.mt100px{
margin-top: 100px;
}
.mt200px{
margin-top: 200px;
}
.h700{
height: 700px;
}
.h800{
height: 800px;
}
.w89{
width: 89%;
}
.mT20{
margin-top: 20%;
}
.mt50p{
margin-top: 50%;
}
The reason your border isn't wrapping the image elements is because the image elements are floated and the container hasn't been cleared.
Anytime you float an image or any other object you take it out of the normal flow. This means that the parent container doesn't even know it exists.
There are several ways to address this issue – known as clearfix methods. In this case I've used the overflow property. Add overflow: auto to the container divs.
.no-hover {overflow: auto;}
.on-hover {overflow: auto;}
I tested this code and it solves the problem.
DEMO
Just keep in mind that when using the overflow property you can have different values (auto, hidden, scroll) each of which will have a different effect when content overflows the container. To understand what each value does you can refer to this article: MDN - CSS Overflow Property
Hope this helps. Good luck!