Footer elements vertical align - html

I'm trying to make this footer, where every element is vertically aligned. But for some reason, copyright for example isn't vertically aligned.
Can anyone help me finding out what is wrong? Or what I am missing?
Footer HTML:
<div id="footerSocial">
<div id="socialNetwork">
Connect with us
<img src="/www/assets/newImages/footer/facebook.png">
<img src="/www/assets/newImages/footer/twitter.png">
<img src="/www/assets/newImages/footer/google plus.png">
<img src="/www/assets/newImages/footer/pinterest.png">
<img src="/www/assets/newImages/footer/tumblr.png">
</div>
<div id="footerNewsletter">
Subscribe to Newsletter
<input id="subscribeNewsletter" name="email" type="text">
<input id="subscribe_ok" type="image" src="/www/assets/newImages/footer/Ok.png" onclick="saveNewsletter(this);">
</div>
<div id="copyright">
Copyright 2013 - Dreaming Different
</div>
</div>
Footer CSS:
#footerSocial {
display: inline-block;
text-align: center;
width: 100%;
margin-top: -25px;
}
#socialNetwork {
display: inline-block;
float: left;
font-size: 10px;
color: #747474;
}
#footerNewsletter {
display: inline-block;
margin: 0 auto;
font-size: 10px;
color: #747474;
}
#footerNewsletter #subscribe_ok {
margin-bottom: -5px;
}
#copyright {
display: inline-block;
float: right;
font-size: 10px;
color: #747474;
}
#footerSocial {
border: 1px solid black;
}
#socialNetwork {
border: 1px solid green;
}
#footerNewsletter {
border: 1px solid red;
}
#copyright {
border: 1px solid blue;
}
Fiddle Demo

You can use a table layout to achieve what you want :
#footerSocial { display: table; text-align: center; width: 100%; font-size: 10px;color: #747474;}
#footerSocial > div {display: table-cell; }
#footerNewsletter #subscribe_ok { margin-bottom: -5px; }
#footerSocial { border: 1px solid black; }
#socialNetwork { border: 1px solid green; }
#footerNewsletter { border: 1px solid red; }
#copyright { border: 1px solid blue; }
Example

Related

HTML/CSS: Can't figure out how to get a divider in a box

I'm very new at this, so sorry if my code is a little messy. I'm trying to create a job search page where the results will show a bar like this:
I've kinda got it, except I can't get that divider in between the PREV, 1 to 100, and NEXT. Mine looks like this:
Here's my code:
HTML:
<div class="results">
<a href="https://gregslist--farahgus10.repl.co/">Prev<a/>
<a href="https://gregslist--farahgus10.repl.co/" >1 to 100 of 179<a/>
<a href="https://gregslist--farahgus10.repl.co/" >Next<a/>
</div>
CSS:
.results {
color: black;
border: 1px solid lightgrey;
width: 300px;
padding: 5px;
margin-top: 25px;
margin-left: 60px;
margin-bottom: 30px;
}
I've tried making a results class for every link, but then I end up getting one big box and 3 little boxes around each link.
.results {
color: black;
border: 1px solid lightgrey;
width: 300px;
margin-top: 25px;
margin-left: 60px;
margin-bottom: 30px;
display:flex;
}
.results a {
color:#000;
text-decoration:none;
font-family:sans-serif;
}
.a, .c {
flex:1;
padding: 5px 0px;
text-align:center;
}
.b {
flex:2;
padding: 5px 0px;
text-align:center;
border-right:1px solid lightgray;
border-left:1px solid lightgray;
}
<div class="results">
<div class="a"><a href="https://gregslist--farahgus10.repl.co/">< Prev<a/></div>
<div class="b"> <a href="https://gregslist--farahgus10.repl.co/" >1 to 100 of 179<a/></div>
<div class="c"> <a href="https://gregslist--farahgus10.repl.co/" >Next ><a/></div>
</div>
Maybe put this in very simple table. I think it should be good enough solution for your need.
Something like this JSFiddle
<table>
<tr>
<td>
Prev
</td>
<td>
<a href="https://gregslist--farahgus10.repl.co/" >1 to 100 of 17</a>
</td>
<td>
<a href="https://gregslist--farahgus10.repl.co/" >Next</a>
</td>
</tr>
</table>
With CSS with base like this
.results {
color: black;
border: 1px solid lightgrey;
width: 300px;
padding: 5px;
margin-top: 25px;
margin-left: 60px;
margin-bottom: 30px;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid gray;
}
Your case is simple enough, don't no fancy flexbox or anything.
.results {
color: black;
border: 1px solid lightgrey;
/* width: 300px; removed */
display: inline-block; /* Added */
/* padding:5px; moved to the children (<a>) */
margin-top: 25px;
margin-left: 60px;
margin-bottom: 30px;
}
/* Added */
a {
display: inline-block;
padding: 5px;
text-decoration: none;
}
/* giving the second child left and right border to mimic dividers */
.results>a:nth-child(2) {
border-right: 1px solid lightgrey;
border-left: 1px solid lightgrey;
}
<div class="results">
Prev
1 to 100 of 179
Next
</div>
Your closing tags on the <a> links are wrong. They should look like </a> with the slash before the a. Once you update those, you can place the <a> links into individual divs:
HTML:
<div id="container">
<div>Prev</div>
<div>1 to 100 of 179</div>
<div>Next</div>
</div>
CSS:
div {
float: left;
}
#container {
border: 1px solid lightgrey;
}
#container div {
padding: 8px 24px;
border-right: 1px solid lightgrey;
}
#container div:last-child {
border-right: none;
}
There are many factors that are needed:
Your elements were badly closed
You need to be more specific to what elements you should apply the CSS
These are just the most notable, you need more CSS information. Much success.
.results {
display: flex;
width: 100%;
padding: 5px;
}
.results a {
max-width: 300px;
min-width: 150px;
color: black;
text-decoration: none;
border: 1px solid lightgrey;
padding: 8px;
text-align: center;
}
<div class="results">
Prev
<a href="#" >1 to 100 of 179</a>
<a href="#" >Next</a>
</div>
<div class="results">
<a href="https://gregslist--farahgus10.repl.co/">Prev<a/>
<a href="https://gregslist--farahgus10.repl.co/" >1 to 100 of 179<a/>
<a href="https://gregslist--farahgus10.repl.co/" >Next<a/>
</div>

Submenu placement HTML

I made my submenu appear when I hover over one option in menu. However when I do it it extends menu height (PIC1). I tried setting menu height on 56px and then it doesn't extend but it ruins my whole layout (PIC2). I also tried putting position:absolute in empty div between menu_option and submenu but then submenu changes sizes and loses attributes (PIC3).
#menu {
margin-bottom: 20px;
background-color: #73818c;
padding: 10px;
}
.menu_option {
float: left;
min-width: 100px;
text-align: center;
border-right: dotted 2px black;
padding: 10px;
font-size: 16px;
}
.submenu {
text-align: center;
border-bottom: dotted 2px black;
padding-top: 10px;
padding-bottom: 10px;
display: none;
font-size: 13px;
}
.submenu:hover {
background-color: white;
}
.menu_option:hover div {
display: block;
}
.menu_option:hover {
background-color: lightgray;
cursor: pointer;
}
<div id="menu">
<div class="menu_option">Strona główna</div>
<div class="menu_option">Galeria</div>
<div class="menu_option">Reżyserzy
<div>
<div class="submenu" style="margin-top:10px">Quentin Tarantino</div>
<div class="submenu">Bracia Coen</div>
<div class="submenu">Wes Anderson</div>
</div>
</div>
<div class="menu_option">Ulubione filmy</div>
<div class="menu_option">Seriale</div>
<div class="menu_option">Kontakt</div>
<div style="clear:both"></div>
</div>
Setting position: absolute on the div that holds the submenus (and position: relative on the menu options) will keep the height of that div (and its contents) from affecting the height of its parent elements.
#menu {
margin-bottom: 20px;
background-color: #73818c;
padding: 10px;
}
#menu, #menu * {
box-sizing: border-box;
}
.menu_option {
float: left;
min-width: 100px;
text-align: center;
border-right: dotted 2px black;
padding: 10px;
font-size: 16px;
position: relative;
}
/* I've added this class to the div around the .submenus */
.submenu_wrapper {
position: absolute;
background: lightgray;
left: 0;
right: 0;
}
.submenu {
text-align: center;
border-bottom: dotted 2px black;
padding-top: 10px;
padding-bottom: 10px;
display: none;
font-size: 13px;
}
.submenu:hover {
background-color: white;
}
.menu_option:hover div {
display: block;
}
.menu_option:hover {
background-color: lightgray;
cursor: pointer;
}
<div id="menu">
<div class="menu_option">Strona główna</div>
<div class="menu_option">Galeria</div>
<div class="menu_option">Reżyserzy
<div class="submenu_wrapper"> <!-- new class -->
<div class="submenu" style="margin-top:10px">Quentin Tarantino</div>
<div class="submenu">Bracia Coen</div>
<div class="submenu">Wes Anderson</div>
</div>
</div>
<div class="menu_option">Ulubione filmy</div>
<div class="menu_option">Seriale</div>
<div class="menu_option">Kontakt</div>
<div style="clear:both"></div>
</div>
add to the end of your CSS
menu_option:hover > div{
position:absolute;
top:10px;
}
.menu_option
{
position:relative;
}
Here is an Example
add an id named main_bx to the div that holds all divs with class .submenu and
.main_bx{
display:none;
}
.menu_option:hover .main_bx {
display: block;
position:absolute;
}
#menu {
margin-bottom: 20px;
background-color: #73818c;
padding: 10px;
height: 40px;
overflow: visible;
}
see snippet below (The window is small so you are going to find some wrapping in this snippet)
#menu {
margin-bottom: 20px;
background-color: #73818c;
padding: 10px;
}
.menu_option {
float: left;
min-width: 100px;
text-align: center;
border-right: dotted 2px black;
padding: 10px;
font-size: 16px;
}
.submenu,.main_bx {
text-align: center;
border-bottom: dotted 2px black;
padding-top: 10px;
padding-bottom: 10px;
font-size: 13px;
}
.submenu:hover {
background-color: white;
}
.main_bx{
display:none;
}
.menu_option:hover .main_bx {
display: block;
position:absolute;
}
.menu_option:hover{
background-color: lightgray;
cursor: pointer;
}
#menu {
margin-bottom: 20px;
background-color: #73818c;
padding: 10px;
}
<div id="menu">
<div class="menu_option">Strona główna</div>
<div class="menu_option">Galeria</div>
<div class="menu_option">Reżyserzy
<div class="main_bx">
<div class="submenu" style="margin-top:10px">Quentin Tarantino</div>
<div class="submenu">Bracia Coen</div>
<div class="submenu">Wes Anderson</div>
</div>
</div>
<div class="menu_option">Ulubione filmy</div>
<div class="menu_option">Seriale</div>
<div class="menu_option">Kontakt</div>
<div style="clear:both"></div>
</div>

Html table like structure without table

I am trying to create 2 column table like structure without using <table> , Here in 2nd column , When the text overflows I want it to stay on the right side.Here is my code so far - https://jsfiddle.net/a49vuup1/
<div class="mainbox">
<span class="leftbox"> STATE </span> : <span class="rightbox">TAMILNADU TAMILNADU TAMILNADU TAMILNADU</span>
<div class="myhr"></div>
<span class="leftbox"> Phone </span> : <span class="rightbox">Landline</span>
</div>
and my css
.mainbox {
max-width: 300px;
margin: auto;
border: 1px solid #454242;
margin-top: 30px;
}
hr {
border-top: 3px solid rgba(44, 44, 44, 0.69);
}
.leftbox {
border-right: 1px solid #303925;
font-size: 20px;
padding: 5px;
min-width: 150px;
display: inline-block;
}
.myhr {
border-bottom: 1px solid #293A42;
}
.rightbox {
font-size: 16px;
min-width: 150px;
}
You could use display: table for this
example:
<div class="table">
<div class="table-row">
<div class="cell">
text 1
</div>
<div class="cell">
text 2
</div>
</div>
<div class="table-row">
<div class="cell">
text 3
</div>
<div class="cell">
text 4
</div>
</div>
</div>
css:
.table {
display: table;
table-layout: fixed;
border-collapse: collapse;
}
.table-row {
display: table-row;
}
.cell {
display: table-cell;
border: 1px solid black;
}
https://jsfiddle.net/41vpjpuy/
I wasn't sure what the <hr> and .myhr was for so I guessed that it was to span both columns. I used display: table-cell for .leftbox and .rightbox and made the .mainbox display: table of course and added table-layout: fixed so your lengths can make more sense.
Reference
Fiddle
Snippet
.mainbox {
max-width: 300px;
margin: auto;
border: 1px solid #454242;
margin-top: 30px;
display: table;
table-layout: fixed;
border-spacing: 3px;
border-collapse: separate;
}
hr {
border-top: 3px solid rgba(44, 44, 44, 1);
width: 200%;
}
.leftbox {
border-right: 1px solid #303925;
font-size: 20px;
padding: 5px;
min-width: 150px;
display: table-cell;
}
.myhr {
border-bottom: 2px solid #000;
display: table-row;
width: 200%;
min-height: 30px;
padding: 5px;
}
.rightbox {
font-size: 16px;
min-width: 150px;
display: table-cell;
}
<div class="mainbox">
<span class="leftbox"> STATE </span> : <span class="rightbox">TAMILNADU TAMILNADU TAMILNADU TAMILNADU</span>
<div class="myhr">
<hr/>
</div>
<span class="leftbox"> Phone </span> : <span class="rightbox">Landline</span>
</div>
Additionally, try this also. I eddited your css and html
<div class="mainbox">
<div class="row">
<span class="leftbox">State</span>: <span class="rightbox">TAMILNADU TAMILNADUTAMILNADU TAMILNADU</span>
</div>
<div class="row">
<span class="leftbox">Phone</span>: <span class="rightbox">landline</span>
</div>
</div>
CSS:
.mainbox {
max-width: 300px;
margin: auto;
border: 1px solid #454242;
margin-top: 30px;
display: table;
}
.row {
display:table-row;
}
{
border-top: 3px solid rgba(44, 44, 44, 0.69);
}
.leftbox {
border-right: 1px solid #303925;
font-size: 20px;
padding: 5px;
min-width: 150px;
word-wrap: break-word;
display: table-cell;
width:25%;
}
.myhr
{
border-bottom: 1px solid #293A42;
}
.rightbox {
/* word-wrap: break-word; */
font-size: 16px;
min-width: 150px;
display:table-cell;
}

Centering a div; not sure what to do

I've been trying for hours to center a table div on a website I'm creating, and I can't figure it out. I've tried using margin: 0 auto with a defined width, and that doesn't work. I've also 'margin-right: auto; margin-left: auto;", but that didn't work either. I'm really not sure what else to try.
Also, I'm trying to fix my footer to stay on the bottom of the page. It'll look great on one page, coming after all the content, but on another page it will be right on top of the content. Should I make another topic for that, or can someone help me out with that in this one?
HTML for the page with the table:
#body {
background-color: #8AD4E6;
font-color: #3E3E3E;
font-family: "Akzidenz Grotesk" sans-serif;
}
#content {
margin-left: auto;
margin-right: auto;
width: 500px;
text-align: center;
vertical-align: middle;
position: relative;
}
#header {
background-color: #6cf;
margin: 10px;
height: 120px;
font-family: "Akzidenz Grotesk" sans-serif;
text-align: center;
color: #4D8B4D;
border: 2px solid black;
}
#headerimg {
border: 2px solid;
float: left;
margin: 10px 5px 5px 5px;
margin-left: 20px;
}
#sidebar{
position: relative;
float: right;
margin: 10px;
padding: 25px;
background-color: #6cf;
border: 2px solid black;
}
.sideheading {
text-align: center;
color: #4D8B4D;
font-family: "Akzidenz Grotesk" sans-serif;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
padding: 5px;
margin-left: 35%;
position: relative;
text-align: center;
vertical-align: middle;
}
table th {
font-style: bold;
}
.female {
background-color: #FFE6FF;
}
.male {
background-color: #D6EBFF;
}
.uni{
background-color: #D4FFD4;
}
#name{
margin-left: 35%;
text-align: center;
vertical-align: middle;
position: relative;
}
#navigation {
list-style-type: none;
margin: 0;
padding: 0;
display: inline;
width: 20px;
background-color: #6EC66E;
margin-left: 44%;
margin-top: 30px;
text-align: center;
}
#navigation li {
display: inline-block;
}
a:link, a:visited {
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #CC6699;
text-align: center;
padding: 4px;
text-decoration: none;
}
a:hover, a:active {
background-color: #4D8B4D;
}
#footer {
position: relative;
margin: 5px;
padding: 5px;
height: 60px;
background-color: #6cf;
border: 2px solid black;
}
`<!DOCTYPE html>
<html>
<head>
<title>Writer's Toolbox</title>
<link rel="stylesheet" type="text/css" href="writerstoolbox.css" />
</head>
<body>
<div id="headerimg">
<img src="logo.jpg" alt="Writer's Toolbox header image" />
</div>
<div id="header"> <h1> Writer's Toolbox</h1><h3>All of your writing needs in one place </h3></div>
<div id="sidebar">
<h3 class="sideheading">
<!-- <img src="" alt="" /> -->
<br />
What are you looking for?
</h3>
<p>Names<br>Settings<br>Character Traits<br>Mary Sue Test<br>Plot ideas<br>Title ideas<br>Writing Tips<br>Resources</p>
</div>
<div id="content">
<h3 id="name">'A' Names</h3><br>
<table id="tablename">
<tr>
<th>Names</th>
<th>Alternate Spelling</th>
<th>Gender </th>
<th>Origin</th>
<th>Meaning</th>
</tr>
<tr class="male">
<td>Aaron</td>
<td>Arron, Aaren</td>
<td>m</td>
<td>Hebrew</td>
<td>Exalted, strong</td>
</tr>
<tr class="male">
<td>Abbott</td>
<td>Abbot</td>
<td>m</td>
<td>English</td>
<td>Head of a monastery</td>
</table>
</div>
<footer id="footer">
<ul id="navigation">
<li>Homepage</li>
<li> | </li>
<li>Back to Names</li>
</ul>
</footer>`
u have some problems with the globe styling like u style the table and it's element together
Any way here's the solution in js fiddle
http://jsfiddle.net/phonexdoda/ze6dddoh/
i changed the #content style to
#content {
width: 1020px;
text-align: center;
vertical-align: middle;
position: relative;
}
add $tablename style
#tablename{
margin: auto;
}
and last the table styling
table, th, td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
padding: 5px;
position: relative;
text-align: center;
vertical-align: middle;
}
and for the #name
#name {
text-align: center;
vertical-align: middle;
position: relative;
}
And the footer need this
#footer {
position: relative;
clear: both;
margin: 5px;
padding: 5px;
height: 60px;
background-color: #6cf;
border: 2px solid black;
}
If you use text-align: center; and vertical-align: middle; in the content class it will try and format the contents of the div to those attributes. These don't apply to the actual div itself.
Create a new div around the content div, like content_container and apply text-align: center; and vertical-align: middle; to the class.
This will center and vertically align your content div.

Centering CSS/HTML text vertically

I am making a webpage using CSS when I encountered a problem. My menu bar doesn't center the links vertically in the bar. It should be really simple, but I need help. Sorry for making it so long, I just didn't want to leave anything out.
HTML:
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<title>noobyDev</title>
<style>
body {
background-color: CCFFFF;
text-align: center;
}
div.background
{
width: 90%;
height: 200px;
background color: #00FF66;
border: 2px solid black;
margin: 0 auto;
text-align: left;
}
div.background h3
{
margin: 0px 40px;
}
div.logo
{
width: 350px;
height: 75px;
background: url(logo.png);
margin: 30px 40px;
}
div.nav
{
background-color: #00CC66;
border: 2px solid black;
width: 90%;
margin: 0 auto;
text-align: left;
height: 30px;
border-top: 0px solid black;
}
.menu
{
margin: 5px 10px;
background: #00CC66;
color: black;
-webkit-transition: color;
}
.menu:hover
{
color: red;
}
div.center
{
width: 90%;
height: 700px;
background color: white;
border: 2px solid black;
border-top: 0px solid black;
margin: 0 auto;
text-align: left;
}
div.column1 h1
{
margin: 30px 40px;
}
div.column1 p
{
margin: 30px 40px;
}
div.column1
{
width: 70%;
height: 100%;
float: left;
display: block;
border-right: 2px solid black;
}
div.column2
{
width: 30%
height: 100%;
float: left;
display: block;
text-align: left;
}
div.column2 a
{
margin: 30px 40px;
display: block;
text-decoration: none;
font-size: 30px;
font-color: black;
}
div.legal
{
width:90%;
height: 50px;
background color: white;
border: 2px solid black;
border-top: 0px solid black;
margin: 0 auto;
text-align: center;
}
</style>
</head>
<body>
<div class="background">
<div class="logo">
</div>
<h3>Have you failed today?</h3>
</div>
<div class="nav">
<a style=text-decoration="none" href="index.html" class="menu">Home</a>
<a style=text-decoration="none" href="html.html" class="menu">HTML</a>
<a style=text-decoration="none" href="javascript.html" class="menu">Javascript</a>
<a style=text-decoration="none" href="css.html" class="menu">CSS</a>
<a style=text-decoration="none" href="java.html" class="menu">Java</a>
<a style=text-decoration="none" href="news.html" class="menu">News</a>
<a style=text-decoration="none" href="games.html" class="menu">Games</a>
<a style=text-decoration="none" href="other.html" class="menu">Other</a>
</font>
</div>
<div class="center">
<div class="column1">
<h1>Home</h1>
<br>
<p>Welcome to noobyDev.com! This is my site where I document all of my fails and successes worth sharing. Feel free to use them unless otherwise instructed to do so. Check back often and admire my awesomeness!</p>
</div>
<div class="column2">
Video?
</div>
</div>
<div class="legal">
<p>This site is heavily protected with a gargantuan army of mutant cotton balls; I would recommend not stirring trouble up. Just so you know, this site looks the best in Internet Explorer.</p>
</div>
</body>
</html>
Just add a line-height to div.nav:
div.nav
{
background-color: #00CC66;
border: 2px solid black;
width: 90%;
margin: 0 auto;
text-align: left;
height: 30px;
line-height: 30px;
}
Here's the JS Bin to test: http://jsbin.com/oliwit/1/
There are generally a lot of misconceptions on how to utilize the vertical-align within CSS, I found this post very helpful on how to get a full understanding of it... http://phrogz.net/css/vertical-align/