Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

vertical align

Featured Replies

<div class="footer">
			<a class="left" href="http://www.thoroprod.com"><img src="images/thoro.png" width="25"> <span>THORO PRODUCTIONS, INC.</span> © 2013 THORO PRODUCTIONS™ ALL RIGHTS RESERVED. </a>
			<a href=""><img src="images/logo2.png" width="25"></a>
			<a href="http://www.youtube.com/thoroprod1"><img src="images/youtube.png" width="25"></a>
			<a href="http://www.twitter.com/rexmakesbeats"><img src="images/twitter.png" width="25"></a>
			<a href="http://www.facebook.com/thoroprod"><img src="images/facebook.png" width="25"></a>
		</div>
/* Footer Style */
.footer{
	position:fixed;
	bottom:0px;
	left:0px;
	width:100%;
	font-size:13px;
	background:#000;
	height:20px;
	padding-bottom:10px;
	text-transform:uppercase;
	z-index:4;
}
.footer a{
	padding:5px 10px;
	letter-spacing:1px;
	text-shadow:1px 1px 1px #000;
	color:#ddd;
	float:right;
}
.footer a:hover{
	color:#fff;
}
.footer a span{
	font-weight:bold;
}
.footer a.left{
	float:left;
}

i have a footer with an image and text, which for some reason are not aligned equally

what is wrong???

 

s17znk.jpg

 

don't you have any web space with your host? or pop the folder with images and the whole page in drop box/google drive/... and share a link

 

without the images and all code it's hard to say e.g. from a screenshot we can't see how high the first image is for example

Edited by dap

Most likely because the text always align image to the bottom unless you specify with CSS

 

This will probably work for you.

 

.footer img {
   vertical-align:middle;
}

If j05hr's suggestion doesn't work try adding a class to the span and then align this using padding/margin.

 

Beware if this is responsive though as you may need to edit the amounts at each break point.

 

Like the carousel, I am just thinking of creating a site using the same one....

There are a number of methods for vertical alignment. Which one you chose would be dependant on the content that needs to be aligned - or more specifically the height of the content.

 

A single line of text for example you can set a line height equal to the parent container and it will be centered, if this text breaks onto multiple lines it will no longer work as expected. -- Not a good solution for dynamic content.

 

An element with a specific height that will not change you can use positioning to position the top to 50% of the parent's height then, add a negative margin top equal to half the height of the element to be centered.

 

But what happens if we do not know the height of the element we want centered - very common occurrence when we have clients adding their own content...

 

Well if we know the height of the container we can do the following:

 

HTML

<div class="parent">
  <div class="table">
    <div class="table-cell">
       Some dynamic contgent
    </div>
  </div>
</div>

And the CSS

.parent {
  height: 300px;
}

.table {
  display: table;
  height 100%;
  width: 100%;
}

.table-cell {
  display: table-cell;
  width: 100%;  /* Or any width you desire, text-align center to center children -- give them display-inline-block */
  vertical-align: middle;
}

 

Works like a charm :)

Fiddle: http://jsfiddle.net/rbrtsmith/y745G/

 

 

BUT what about if we don't know the height of the parent or the content to be vertically centered.... hmm

 

Well there is a solution!

 

 

You can give the parent with the unknown height a position of relative, then insert a child element to sit over the top of the parent. give it position absolute and top, right, bottom and left attributes of 0.

Then you nest the table solution above inside of this and now we have a totally dynamic solution to vertically aligning content.

 

Fiddle: http://jsfiddle.net/rbrtsmith/MwZxk/

 

In the above fiddle I made the height of the parent dynamic to be relative to the screen width using the height 0 and padding-bottom a percentage. Resze the window and you will see how dynamic the solution is.

 

Here is an example of me using the technique above for the content of a slider in a project I worked on: http://lidingolas.se/

  • 2 weeks later...

Do this simple Modification and i hope it solves your issue.

 

 

**********************************************************************************************************

<style>
/* Footer Style */
.footer{
position:fixed;
bottom:0px;
left:0px;
width:100%;
font-size:13px;
background:#000;
height:20px;
padding-bottom:10px;
text-transform:uppercase;
z-index:4;
}
.footer a{
padding:5px 10px;
letter-spacing:1px;
text-shadow:1px 1px 1px #000;
color:#ddd;
float:right;
}
.footer a:hover{
color:#fff;
}
.footer a span{
font-weight:bold;
position: relative;
bottom: 8px;
}
.footer a.left{
float:left;
}
.fleft{ float:left;}
</style>
<div class="footer">
<div class="fleft">
<img src="images/thoro.png" width="25">
<span>THORO PRODUCTIONS, INC. © 2013 THORO PRODUCTIONS™ ALL RIGHTS RESERVED. </span>
</a>
</div>
<div class="fright">
<a href=""><img src="images/logo2.png" width="25"></a>
<a href="http://www.youtube.com/thoroprod1"><img src="images/youtube.png" width="25"></a>
<a href="http://www.twitter.com/rexmakesbeats"><img src="images/twitter.png" width="25"></a>
<a href="http://www.facebook.com/thoroprod"><img src="images/facebook.png" width="25"></a>
</div>
***********************************************************************************************************************

i dont have a webhost at the moment, sorry

You can always use a free host, there are many to available. I use ooowebhost.com for my free hosting although many frown at them I have no problems when using it for a 'live version to work with'.

 

As to a solution to your vertical alignment problem have a read of this article on Codrops, It uses a method that can be applied to any section of the page and remains stable in responsive grids as well! (Although I have recently had a problem with stack context affecting it)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.