PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 17, 2022

[FIXED] How can I vertically align text in my footer and also remove underline from ::after content

 November 17, 2022     css, html, vertical-alignment     No comments   

Issue

So I have two questions:

1. How can I vertically align text in my footer with two or more lines?

(I'm justing line-height with the height of footer to align one line but it leaves huge gaps between two or more lines)

2. How can I remove underline from CSS ::after content thing but keep it under the text.

(so all Links will look on hover like the last one)

HTML & CSS

    footer {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      min-height: 50px;
      line-height: 50px;
      text-align: center;
      margin-top: auto;
      margin-bottom: auto;
      color: white;
      background-color: #232323;
    }
    
    footer a {
      cursor: pointer;
    }
    
    footer a:hover {
      text-decoration: underline;
    }
    
    footer a:not(:last-child)::after {
      content: " | ";
      cursor: default;
    }
<footer>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
    <a>Link</a>
</footer>

JSFIDDLE
https://jsfiddle.net/qmbbtmb5/


Solution

You can make it work like you want by adding position: absolute css property to the :after pseudo selector. Try adjusting your css code like this one.

footer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  min-height: 50px;
  text-align: center;
  line-height: 1.5;
  margin-top: auto;
  margin-bottom: auto;
  color: white;
  background-color: #232323;
  padding: 30px 0;
}

footer a {
  cursor: pointer;
  display: inline-block;
  position: relative;
  margin: 0 5px;
}

footer a:hover {
  text-decoration: underline;
}

footer a:not(:last-child)::after {
  content: " | ";
  cursor: default;
  position: absolute;
  top: 0;
  right: -10px;
}


Answered By - Aryan Twanju
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing