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 8670823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:47:54+00:00 2026-06-12T18:47:54+00:00

I know vertical center in CSS is a pain to begin with, but I’ve

  • 0

I know vertical center in CSS is a pain to begin with, but I’ve just made it a bit more complicated. On my page, I have:

<ul id="complete">
</ul>

<form id="new_item_form">
  <input type="text" id="add_item" placeholder="Type some tasks here"/>
</form>

<ul id="incomplete">
</ul>

It’s for a basic task list. Tasks are added to the incomplete ul, and when completed move to the complete ul. What I want to do via css is have the text field vertically centered on the page and stay there, with the two lists butted up against it. I’ve been looking at all sorts of vertical alignment (a summary of forms found here: http://blog.themeforest.net/tutorials/vertical-centering-with-css/ ) but I can’t seem to find a way that I can figure out how to adapt to allow what I need. How would I accomplish this style of fixed position centering?

EDIT:
Here’s an image of what I’m looking for: https://www.dropbox.com/s/i0oit3v84j93b5g/Screen%20Shot%202012-10-11%20at%204.27.16%20PM.png

  • 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-06-12T18:47:55+00:00Added an answer on June 12, 2026 at 6:47 pm

    I can’t think of any way to do this with CSS, but it’s fairly easy to do with JavaScript/jQuery. Here is a working jsFiddle that does what you want on document load. You’d call the code again if you changed the lists, of course.

    First, you enclose your lists and form in a div. I called this id=”cmiddle”. Then you use CSS to set the cmiddle div as position: relative. Then you use JavaScript code to get the enclosing window or frame height, calculate the center for the form, and then, subtract the upper list height to get the correct div position:

    $(document).ready(function(e) {
        // To work with frames, too
        function getParentDocHeight($ele) {
            for (;;) {
                if (!$ele || !$ele.length) {
                    return $(window).height();
                }
                $ele = $ele.parent();
                if ($ele.is("frame") || $ele.is("window")) {
                    return $ele.height();
                }
            }
        }
        var $cm = $("#cmiddle");
        var formHeight = $("#new_item_form").outerHeight();
        var viewHeight = getParentDocHeight($cm)
        var formTop = (viewHeight - formHeight) / 2;
        var divTop = formTop - $("#complete").outerHeight();
        $cm.css("top", divTop);
    });
    

    Edit: Kraz was nice enough to add a simulation of adding list items to both lists and calling the code again to recalc. His jsFiddle here.

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

Sidebar

Related Questions

Does anyone know how to center a vertical drop down menu for all screen
I have a problem with the Height Tag in CSS. I want the page
Variations on this question have been asked many times. Vertical centering with CSS is
I have a ul that I want to center vertically to the vertical center
I want to know what is vertical tab, form feeds and backspace character and
I know you can do this to get vertical text in a tab header:
I want to know if the element is showing vertical scrollbars or not, and
Does anyone know if it's possible to create vertical text in a html5 canvas
I trying to determine display vertical size of my Blackberry Storm 2. I know,
Know this might be rather basic, but I been trying to figure out how

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.