-1

I'm really sorry to bring this question up since I know there are answers on this. I have read and read and can't seem to make it work. Obviously there's something I'm doing wrong so if you could explain to me what I'm supposed to do and why I'd be really thankful.

footer {
  display: inline-block;
  position: relative;
  height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}
footer p {
  display: inline-block;
  vertical-align: middle;
  line-height: 1vh;
}
<footer>
  <p>Copyright 2016 - Say my name. All Rights Reserved</p>
</footer>
Sebastian Brosch
  • 37,059
  • 14
  • 61
  • 73
Emric Månsson
  • 185
  • 1
  • 13
  • Possible duplicate of [Vertically align text in a div](http://stackoverflow.com/questions/2939914/vertically-align-text-in-a-div) – jperezov Feb 03 '16 at 18:21
  • 2
    Instead of a paragraph of apologies, please post a question with details. – j08691 Feb 03 '16 at 18:23

4 Answers4

1

You don't need paragraph tags within the footer; just add line-height: 15vh; to your footer, and remove the surrounding paragraph tags.

footer {
  display: inline-block;
  position: relative;
  height: 15vh;
  line-height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}
<footer>
  Copyright 2016 - Say my name. All Rights Reserved
</footer>
Shea Hunter Belsky
  • 1,521
  • 1
  • 17
  • 25
1

You can use display:table and display:table-cell property. Vertically centered text

HTML:

<footer>
  <p>Copyright 2016 - Say my name. All Rights Reserved</p>
</footer>

CSS:

footer {
  display: table;
  position: relative;
  height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}
footer p {
  display: table-cell;
  vertical-align: middle;
  line-height: 1vh;
}

footer {
  display: table;
  position: relative;
  height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}
footer p {
  display: table-cell;
  vertical-align: middle;
  line-height: 1vh;
}
<footer>
  <p>Copyright 2016 - Say my name. All Rights Reserved</p>
</footer>

Or you can use flex property,but its not supported by many browser version Align using flex property

CSS:

footer {
  display: flex;
  justify-content: center;        /* align horizontal */
  align-items: center;        /*ALIGN VERTICAL*/
  position: relative;
  height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}

footer p {  
   line-height: 1vh;
}

footer {
  display: flex;
  justify-content: center;        /* align horizontal */
  align-items: center;        /*ALIGN VERTICAL*/
  position: relative;
  height: 15vh;
  width: 100vw;
  background: #1a1a1a;
  border-top: 1px solid #232323;
  color: #a0a0a0;
  padding-left: 5%;
  box-sizing: border-box;
}

footer p {
  
  vertical-align: middle;
  line-height: 1vh;
}
<footer>
  <p>Copyright 2016 - Say my name. All Rights Reserved</p>
</footer>
Pbk1303
  • 3,292
  • 2
  • 25
  • 43
0

Try this CSS:

footer {
        display: table-cell; 
        vertical-align: middle;
        text-align: center;
}
pivemi
  • 708
  • 8
  • 14
-1
footer p {
  display: inline-block;
  vertical-align: middle;
  line-height: 1vh;
  vertical-align: middle;
}
lacexd
  • 843
  • 6
  • 21