Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:14:45+00:00 2026-05-25T15:14:45+00:00

EDIT: I apologize if this has been asked before or is a well-known techinque.

  • 0

EDIT: I apologize if this has been asked before or is a well-known techinque. I didn’t know what this would be called and hence I was unable to search for it.

In my HTML document, I vertically center something as follows:

<div style='position:  absolute; margin:  auto; top:  0; bottom:  0; height:  500px'>
<!-- CONTENT HERE -->
</div>

This works great, the only problem is, the code isn’t quite reusable because it depends on the particular height of the block. What I would like to do is something like this:

<div class='vcenter(500px)'>
<!-- CONTENT HERE -->
</div>

.vcenter(height)
{
    position:  absolute;
    margin:  auto;
    top:  0;
    bottom:  0;
    height:  height;
}

If I could implement something like this, then I would not have to duplicate code every time I wanted to vertically center something. Does CSS have a way of implementing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:14:46+00:00Added an answer on May 25, 2026 at 3:14 pm

    You could use a css expression, but dont. It’s badly supported by browsers and bad practice.

    I would recommend using a css generating tool:
    http://lesscss.org/ or http://compass-style.org/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I apologize if this has been asked before, but I haven't quite found the
First, I apologize if this has been asked before - indeed I'm sure it
If this has been asked before, I apologize but this is kinda of a
I apologize if this has been asked before. I searched but did not find
If this has been asked before, I apologize. If I had a currently deployed
First off - apologies if this or a similar question has been asked before.
Apologies if this has been asked before. I searched and couldn't find it. In
Apologies if this has been answered before (I couldn't find the answer when I
Ok. First let me apologize profusely if this question has been covered. I did
Apologies if this question has been answered before. Though the answers I've seen look

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.