Solved

Vertical alignment of multiple elements compatible with many browsers?

Posted on 2007-11-15
6
461 Views
Last Modified: 2008-02-01
I have three things I'd like to align vertically, but not using tables. Just using css.  Is there a workaround/hack/solution that is compatible with the major browsers (and versions)?  

<h1>This is a title</h1>
<input type="text" name="" value="a text box">
<input type="image" src="sample.gif" name="">

The text box is a bit larger than the <h1> element, and the image, is a bit larger than the textbox, thus, the desire to have them all vertically aligned in the middle of a div that has a height of 100px.  

Help?
0
Comment
Question by:n00b0101
  • 4
  • 2
6 Comments
 
LVL 14

Expert Comment

by:cezarF
ID: 20295789
try this...

<div style="height:100px;border:1px solid;">
<h1 style="vertical-align: middle;">This is a title</h1>
<input type="text" name="" value="a text box" style="vertical-align: middle;">
<input type="image" src="sample.gif" name="" style="vertical-align: middle;">
</div>



0
 

Author Comment

by:n00b0101
ID: 20295851
doesn't work in ie.... that's okay though.  i wound up create 3 separate divs and using float: left for each, but, if there's a better solution, i'm all ears.
0
 
LVL 14

Expert Comment

by:cezarF
ID: 20295879
are you referring to the title not being in the same line as the text box and image?

I used ie to test and its ok.  
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 14

Accepted Solution

by:
cezarF earned 500 total points
ID: 20296026
this one worked but had to remove <h1>


<div style="display: table; height: 100px;  #position: relative; overflow: hidden; border:1px solid">
    <div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">
      <div style=" #position: relative; #top: -50%;">
		This is a title
		<input type="text" name="" value="a text box" style="vertical-align: middle;">
		<input type="image" src="sample.gif" name="" style="vertical-align: middle;">
      </div>
    </div>
  </div>

Open in new window

0
 

Author Comment

by:n00b0101
ID: 20296235
what version of ie?  ie7 is okay, but >7, not working for me.  :/
0
 
LVL 14

Expert Comment

by:cezarF
ID: 20296449
ie 6 and ff 2
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use question mark (?) in filename with html 25 73
Hide un-named HTML Label with CSS 14 36
Javascript the "if condition with Or" 8 29
Responsive Font Size 6 29
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question