Solved

get label and textbox to align vertically

Posted on 2009-07-15
3
749 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now