+ Reply to Thread
Results 1 to 9 of 9

Thread: Aligning Label and Input elements using ul and li

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Aligning Label and Input elements using ul and li

    I've used this previously and it worked fine. However, in this case, the label and input box won't align vertically. This is when viewed in Design View of VS.

    For some reason the Label text is lying slightly below the line of the textbox. I've tried adding a line-height to both, which helps to a degree, but it still doesn't look right to my eye. The text is still slightly below vertical alignment.

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Ascent.login" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <link href="css/login.css" rel="stylesheet" type="text/css" />
        <link href="css/text.css" rel="stylesheet" type="text/css" />
        <link href="css/master.css" rel="stylesheet" type="text/css" />
        <title>Login</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="holder">
            <div id="logo">
            </div>
            <div id="main">
                <div id="padlock">
                </div>
                <div id="content" class="size_10 bold blue_333399">
                    THIS IS A SECURE SITE.<br />
                    UNAUTHORISED ACCESS IS NOT PERMITTED
                    <div style="text-align:top; vertical-align:middle;">
                        <ul id="login" class="input-fields">
                            <li>
                                <asp:Label ID="lblUserName" runat="server" Text="Username" />
                                <asp:TextBox ID="txtUserName" runat="server" CssClass="textbox" Width="200px" MaxLength="15" />
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </body>
    </html>
    
    CSS
    Code:
    body
    {
        width:100%;
        height:100%;
    }
    
    ul.input-fields
    {
        width:100%;
        list-style-position: outside;
        list-style-type: none;
        margin: 0 auto 3px auto;
        padding: 0;
    }
    ul.input-fields li
    {
        margin: 0;
        text-align:left;
    }
    ul.input-fields label, ul.input-fields span
    {
        text-align:right;
        display: inline-block;
        min-width:15em;
        width: 40%;
    }
    ul.input-fields input, ul.input-fields select, ul.input-fields textarea
    {
        margin: 2px 0;
    }
    
    input.textbox
    {
        margin:0;
        border:solid 1px #CCCCCC;
        background-color: #EDF0FD;
    }
    #holder
    {
        text-align:center;
        vertical-align:middle;
        width:50%;
        height:50%;
        border:solid 1px #CCCCCC;
    }
    
    #logo
    {
        height:100px;
        width:357px;
        background-image:url('../images/logo.jpg');
        background-repeat:no-repeat;
    }
    
    #main
    {
        margin:0;
        margin-top:20px;
        width:100%;
        margin-left:auto;
        margin-right:auto;
    }
    
    #padlock
    {
        margin-top:-20px;
        float:left;
        height:128px;
        width:90px;
        background-image:url('../images/padlock.png');
        background-repeat:no-repeat;
    }
    
    #content
    {
        float:right;
        text-align:center;
    }
    
    Like I say, I've used this before and everything aligned fine.

    Don't know if it's something I need to change with the holding div or what. If I just put text in the <li> it appears fine. As soon as I add a textbox control, the alignment goes.

    Any ideas?

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Hate to be a downer, but I NEVER use the designer in Visual Studio when building a page. Far too often, it mungs up the page or just never looks 'right'. Pretty much just roll my own in the editor and make sure it's pretty in FireFox.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Yeah. I did wonder if it might just be the design view. I never normally bother with it, but I thought I'd give it a go this time as I tend to test on the server which means uploading each time.

    I now have it looking right in VS, so I guess that'll mean it'll look wrong when I actually test it in the browser...

    btw, the CSS I used was:-
    Code:
    ul.input-fields
    {
        width:100%;
        list-style-position: outside;
        list-style-type: none;
        margin: 0;
        padding: 0;
    }
    
    ul.input-fields label, ul.input-fields span
    {
        float:left;
        text-align:right;
        width: 35%;
        padding-right:5px;
    }
    ul.input-fields input, ul.input-fields select, ul.input-fields textarea
    {
        float:left;
        margin: 0;
    }
    
    which I found on http://woork.blogspot.com/2008/06/fo...-and-list.html

  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    ..more likely it will look different in IE, FF, Opera, Safari, Crome. Oh, and probably different in IE6, IE7, IE8...gonna love it.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  5. #5
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Indeed...I NEVER use Design View in VS. Just open it in a browser...
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  6. #6
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Yeah, I know....Feckin' browsers!!

    I've never yet got anything to look right in Chrome...

  7. #7
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Yep, just loaded it in FF and it's all over the shop...LMAO...

  8. #8
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Also what you'll see in VS design view will be similar in IE......... but might not in FF

  9. #9
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Yep..Given up on VS design view...

+ Reply to Thread

Similar Threads

  1. Aligning 2 divs with the 1 div above
    By richyrich in forum HTML & CSS Help
    Replies: 14
    Last Post: June 26th, 2009, 10:17 AM
  2. Bold Label CSS problem
    By todd2006 in forum HTML & CSS Help
    Replies: 1
    Last Post: April 2nd, 2009, 08:10 PM
  3. navigating records darkens label text in tab control
    By tuxalot in forum Microsoft Access
    Replies: 3
    Last Post: March 23rd, 2009, 01:09 AM
  4. Form Design: Label in Header Control in details
    By nboscaino in forum Microsoft Access
    Replies: 2
    Last Post: August 28th, 2008, 07:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO