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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:22+00:00 2026-05-25T06:39:22+00:00

What I’m trying to do: Vertically center the form in the left div. The

  • 0

What I’m trying to do:

Vertically center the form in the left div. The height of that div should be dependent on the height of the right div which can change depending on the text contained therein.

What I want:

A modern solution that doesn’t resort to using JavaScript. There are many JavaScript-free approaches but as soon as you factor in floated divs and dynamic heights that list dramatically shrinks. I haven’t found a working solution yet, yet alone a modern one.

Here’s the jsfiddle (but I suggest using the raw code):

pshpV

Here’s the raw code:

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />

        <style type="text/css">
            body
            {
                margin: 10px;

                padding: 10px;

                background: #293134;
                color: #E0E2E4;

                border: 1px solid #93C763;
            }

            #container
            {
                overflow: hidden;

                width: 800px;

                margin: 0 auto;

                padding: 10px;

                border: 1px solid #678CB1;
            }

            #left
            {
                float: left;

                width: 568px;

                padding: 10px;

                border: 1px solid #FFCD22;
            }

            #right
            {
                float: left;

                width: 200px;

                margin-left: 10px;

                padding: 10px;

                border: 1px solid #EC7600;
            }

            #container, #left, #right
            {
                box-sizing: border-box;
                -moz-box-sizing: border-box;
                -webkit-box-sizing: border-box;
            }
        </style>
    </head>

    <body>
        <div id="container">
            <div id="left">
                <form>
                    <input type="text" name="keyword" required placeholder="keyword" />

                    <input type="submit" value="search" />
                </form>
            </div>

            <div id="right">
                <h1>foo</h1>
                <h2>bar</h2>
                <h3>baz</h3>
            </div>
        </div>
    </body>
</html>

Hindsights:

As far as I know, the only way the table approach works is by removing the floats. It also appears that I apparently don’t even need the floats. Regardless, I would still like to discover the answer my question.

  • 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-25T06:39:22+00:00Added an answer on May 25, 2026 at 6:39 am

    Not quite sure exactly how you want everything but you could try fiddling about with the display:table / table-cell and then vertical-align. However, IE has issues with these properties. <= IE7 I think

    Edit: I would go out on a limb here and say that what your asking is impossible. The trouble comes from the two requirements you are asking for combined – floating and dynamic heights.

    Floating an element means that the parent element won’t recognize its height, even if you float the parent element as well, it will stretch to the height of floating children but still won’t have a recognized height. Therefore, trying center-aligning tactics like positioning relatively with top:50% won’t work because the height is not recognized.

    In all cases, the actual height of your elements in question will never be recognized because they are floating. You would have to specify heights to parent elements to get around that problem and this won’t work in your case because that is another requirement of yours – dynamic heights.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.