Solved

get label and textbox to align vertically

Posted on 2009-07-15
3
753 Views
Last Modified: 2012-05-07
How do I get the Label text and the Text Box to align vertically at their middles?

See screenshot

thx!
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AddToCart.ascx.cs" Inherits="Spatz.controls.AddToCart" %>
 
<link rel="Stylesheet" href="../css/addtocart.css" type="text/css" />
 
<div id="addtocartdiv">
 
<div id="addtocarbgdiv">
<asp:Image ID="addtocartimage" runat="server" ImageUrl="~/img/addtocart_background.gif" />
</div>
 
<div id="quantitydiv">
<asp:Label ID="LabelQuantity" runat="server" Text="Quantity:"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBoxQuantity" runat="server" Width="35px"></asp:TextBox>
</div>
 
<div id="addtocartbuttondiv">
<asp:Image ID="addtocartbutton" runat="server" ImageUrl="~/img/addtocart_button.jpg" />
</div>
 
</div>

Open in new window

vertalign.jpg
0
Comment
Question by:knowlton
  • 2
3 Comments
 
LVL 5

Author Comment

by:knowlton
ID: 24864447
addtocart.css file:
#addtocartdiv
{    
 
}
 
#addtocarbgdiv
{
    position:relative;
}
 
#quantitydiv
{
    vertical-align:top;
    position:absolute;
    width:120px;
    margin: 0 auto;
    top:20px;
    left:20px;
}
 
#addtocartbuttondiv
{
    position:absolute;
    top:50px;
    left:20px;
}

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24864730
add this class to your css
.aligncenter
{
    vertical-align:middle;
}
then
<div id="quantitydiv">
<asp:Label ID="LabelQuantity" CssClass="aligncenter" runat="server" Text="Quantity:"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBoxQuantity" CssClass="aligncenter" runat="server" Width="35px"></asp:TextBox>
</div>
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 31604007
thx
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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