Solved

Vertical alignment of multiple elements compatible with many browsers?

Posted on 2007-11-15
6
463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 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