Solved

get label and textbox to align vertically

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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 …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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