Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Vertical alignment of multiple elements compatible with many browsers?

Posted on 2007-11-15
6
Medium Priority
?
469 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Accepted Solution

by:
cezarF earned 2000 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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

610 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