I would like to know how position my text on footer directly under each other in three different column
right now only the left column is good the center and the right column are broken
.footer {
/* The dividing footer: */
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 200px;
background-color: #efebe785;
color: #000000;
text-align: center;
border: 1px solid #00000094;
}
.left {
text-align: left;
float: left;
top: 1em;
left: 1em;
}
.right {
float: right;
text-align: right;
top: 1em;
right: 1em;
position: relative;
display: inline;
}
.centered {
text-align: center;
top: 1em;
position: relative;
display: inline;
padding
}
<div class="footer">
<div class="left">
<p class="left">
<font size="5">SOCIAL</font> <br/><br/>
<font size="3">Facebook </font> <br/><br/>
<font size="3"> Twitter </font> <br/><br/>
<font size="3"> Youtube </font>
</p>
</div>
<div class="right">
<p class="right">
<font size="5">EXTRA</font> <br/><br/>
<font size="3">Our Chefs</font>
</p>
</div>
<div class="center">
<p class="centered">
<font size="5">SUPPORT</font> <br/><br/>
<font size="3">Tellphone</font> <br/><br/>
<font size="3">Email</font>
</p>
</div>
</div>
The text isn't aligned correctly in the center and right columns because they have the text alignment of center and right instead of left.
Rather than building your columns using text alignment, you can set them all to be a third of the parent's width, and give them all left-aligned text. See the following snippet.
.footer {
/* The dividing footer: */
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 200px;
background-color: #efebe785;
color: #000000;
/* Align all the text left so it lines up */
text-align: left;
border: 1px solid #00000094;
}
/* Build 3 equal-width columns inside the footer */
.left,
.right,
.center {
float: left;
width: 33.333%;
position: relative;
box-sizing: border-box;
padding-right: 15px;
padding-left: 15px;
}
<div class="footer">
<div class="left">
<p class="left">
<font size="5">SOCIAL</font> <br/><br/>
<font size="3">Facebook </font> <br/><br/>
<font size="3"> Twitter </font> <br/><br/>
<font size="3"> Youtube </font>
</p>
</div>
<div class="right">
<p class="right">
<font size="5">EXTRA</font> <br/><br/>
<font size="3">Our Chefs</font>
</p>
</div>
<div class="center">
<p class="center">
<font size="5">SUPPORT</font> <br/><br/>
<font size="3">Tellphone</font> <br/><br/>
<font size="3">Email</font>
</p>
</div>
</div>
When you have a list of items, it's a very good practice to use <li></li> tag. In this case, you have links, and for link destination, you should use . Each HTML Tag is created for a specific purpose.
And, for the columns layout, I have used CSS Grid Layout.
Grid Layout its very powerful, it helps you to organize your layout in many different ways. You just have to specify to a parent element display: grid;, and add here how you want to display columns. In our case, we have three columns, and these columns have same width, so, I have added grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
Fr is a fractional unit and 1fr is for 1 part of the available space
For a better reference, I would suggest this: Complete Guide To CSS Grid System
Hope I've been clear!
Your code structure should look something like this:
.footer {
/* The dividing footer: */
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 200px;
background-color: #efebe785;
color: #000000;
text-align: center;
border: 1px solid #00000094;
padding: 0 20px;
}
ul {
padding: 0;
}
ul li {
list-style: none;
}
.links {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
}
.links li {
margin-bottom: 10px;
}
.link-item {
padding: 0;
text-align: left;
}
.link-item.centered {
text-align: center;
}
.link-item.right-aligned {
text-align: right;
}
.link-item a {
color: #333;
font-size: 16px;
text-decoration: none;
}
.link-item a:hover {
color: blue;
}
<div class="footer">
<div class="links">
<div class="link-item">
<h3>Social</h3>
<ul>
<li>
Facebook
</li>
<li>
Twitter
</li>
<li>
Youtube
</li>
</ul>
</div>
<div class="link-item centered">
<h3>Support</h3>
<ul>
<li>
Tel
</li>
<li>
Email
</li>
</ul>
</div>
<div class="link-item right-aligned">
<h3>Extra</h3>
<ul>
<li>
Our Chefs
</li>
</ul>
</div>
</div>
This is the css you need (use flex):
.footer{
/* The dividing footer: */
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height:200px;
background-color: #efebe785;
color: #000000;
text-align: center;
border:1px solid #00000094;
display: flex;
}
.left, .center, .right{
flex-grow:1
}
https://jsfiddle.net/8wxn9sp4/
Related
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>
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.
I have kind of titles on my website which looks like this:
The problem appears when I rezise the window:
My text is being moved up and I want it to stretch down. Here is my HTML code:
<div class="inner, header2">
<div class="first">
<img src="images/clean/kim_icon.png" alt="" />
</div>
<div class="second">
<p class="section">S.I.M.B.A. (Smart Infant Management and Breath Aid)</p>
</div>
</div>
And my CSS:
.header2 {
text-align: left;
padding: 3em 6em 0em 6em;
overflow: hidden;
position: relative;
}
.first { //image
float: left;
}
.second { //text
float: left;
position: absolute;
bottom: 0em;
left: 12em;
}
p{
font-size: 2.75em;
margin-bottom: 1em;
line-height: 100%;
margin: 0 0 2em 0;
}
An option is to use a flexbox. The text will be placed at the bottom where possible.
.header2 {
display: flex;
}
.second {
align-self: flex-end;
}
p {
font-size: 2.75em;
margin: 0;
}
<div class="inner header2">
<div class="first">
<img src="http://placehold.it/100" alt="" />
</div>
<div class="second">
<p class="section">S.I.M.B.A. (Smart Infant Management and Breath Aid)</p>
</div>
</div>
I have been at this for a while, here is my HTML and CSS together kind of simplified. I'm sure it's something simple but I cant figure it out for the life of me. I just need to remove the white space in between the border and my content.
<!DOCTYPE html>
<html lang="en-US">
<head>
<!--CSS Internal Style Sheet-->
<style>
HTML
{
border: 20px solid gray;
margin: auto;
}
#center
{
background-color: #EEE8AA;
padding: 0;
}
p
{
text-align: left;
margin-left: auto;
margin-right: auto;
padding: inherit;
width: 800px;
}
dl
{
text-align: left;
margin-left: auto;
margin-right: auto;
top-padding: 10px;
height: 500px;
width: 800px;
}
.box
{
background-color: #DCDCDC;
border: 1px solid #666;
padding: 5px;
}
#banner
{
position: relative;
top: 0px;
left: 0px;
right: 0px;
width: 100%;
height: 200px;
background-image: url(file:///C:/Users/Tollis/Documents/Website/Banner.png)
}
header
{
text-align: center;
font-size: 50px;
padding: 0;
background-color: #98FB98;
}
.menu
{
text-align: center;
padding-bottom: 30px;
padding-top: 30px;
background-color: #98FB98;
}
ul
{
list-style-type: none;
margin: 0;
padding: 0;
}
li
{
display: inline;
}
</style>
<title> Module One Activity </title>
</head>
<body>
<header> Module One Activity </header>
<!--Navigation Bar-->
<div class="menu">
<ul>
<li> Page 1 </li>
   
<li> Page 2 </li>
   
<li> Page 3 </li>
   
<li> Page 4 </li>
</ul>
<div id="center">
<hr>
<p class="box" text-align="center"> <i> <b> Statement: </b> If students are allowed to use technology such as computers, calculators and tablets, then they will be able to develop a deeper understanding of the math concepts presented within their course. </i> </p>
<hr>
<h2 class="back" align="center"> Part 1 </h2>
<p> <b> Inverse: </b> If students are not allowed to use technology such as computers, calculators and tablets, then they will not be able to develop a deeper understanding of the math concepts presented within their course.</p>
<br>
<hr>
</div>
</body>
<footer>
<p> Created by: Tollis Hunt </p>
<p> Contact information: Email me! </p>
<br>
</footer>
Try this in your CSS:
body
{
margin:0;
padding:0;
}
This will remove your white space between content and border.
Hope it helps.
Demo
I am trying to align multiple divs (buttonNav) to the bottom of a container div (lowerNav). I have read every question on here regarding this and tried the CSS and it does not seem to work. I tried this one: Stacking Divs from Bottom to Top amoung others, hoping someone can help.
Here is my html, I have 5 of the lowerNav containers each with multiple buttonNavs that I want to align to the bottom of the lowerNav here is the code from one, they are all set up the same way:
<div class="lowerNav">
<img src="image/contact-us.gif" width="126" height="27" alt=""/>
<p>Ready to get more information or contact us directly?</p>
<div class="buttonNav">
<p>Order Literature</p>
</div>
<div class="buttonNav">
<p>Downloads</p>
</div>
<div class="buttonNav">
<p>Email Sign-Up</p>
</div>
<div class="buttonNav">
<p>Meet Your Rep</p>
</div>
<div class="buttonNav">
<p>Ask a Question</p>
</div>
</div>
Here is my CSS:
.lowerNav {
width: 160px;
height: 325px;
background-color: #e3dfd7;
border: 3px solid #383431;
float: left;
margin: 15px 8px 0px 8px;
text-align: left;
display: table-cell;
vertical-align: bottom;
}
.lowerNav p {
padding: 5px 12px 12px 12px;
}
.lowerNav img {
padding-top: 12px;
}
.buttonNav {
background:url(image/button-lowerNav.jpg);
width: 160px;
height: 45px;
display: inline-block;
}
.buttonNav p {
text-align:center;
padding-top: 14px;
}
.buttonNav a {
color: #fff;
font-size: 13px;
text-decoration:none;
font-weight:700;
}
.buttonNav a:hover {
color: #fff;
font-size: 13px;
text-decoration:underline;
font-weight:700;
}
Since the container (.lowerNav) has a fixed height and you know the size of its content this is quite easy to do with absolute positioning.
HTML:
<div class="outer">
Hello up here!
<ul class="inner">
<li>Hello</li>
<li>down</li>
<li>there!</li>
</ul>
</div>
CSS:
.outer {
position: relative;
height: 200px;
}
.inner {
position: absolute;
bottom: 0;
}
Check this CodePen for a live example of this code: http://codepen.io/EvilOatmeal/pen/fCzIv