Results 1 to 5 of 5

Thread: aligning controls

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    aligning controls

    hi, how would you design a search box to position control properly.

    Code:
                <div id="search_div"   style=" height:74px; background-image : url(Images/search_box.jpg); background-repeat: no-repeat;">                
                    <ul class="search_box" style="margin-left:70px;">
                        <li><asp:DropDownList ID="DropDownList1" runat="server" Width="120px" BackColor="Transparent" CssClass="obj_nolayout">
                                    <asp:ListItem>Delivery No</asp:ListItem>
                                    <asp:ListItem>LPO No</asp:ListItem>
                                    <asp:ListItem>Supplier</asp:ListItem>
                                    <asp:ListItem>LPO Details</asp:ListItem>
                                    </asp:DropDownList></li>
                        <li ><asp:TextBox ID="TextBox1" runat="server" Width="314px" BackColor="Transparent" BorderColor="Gray"></asp:TextBox></li>
                       <li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
                        <li> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/search_go.jpg" /></li>
                    </ul>                
                </div>



    thanks.
    Learn something new every .001 second.

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: aligning controls

    If the rounded corner black background image was a fixed size (didn't need to stretch) then I'd do something like the following. Please excuse mistakes I'm doing it on the fly but it should be enough to demonstrate. You may need another nested div to hold the controls, I'd try to do it without though.

    Code:
    <style>
    
    #search_div{
    height:74px; 
    width:400px;
    background-image : url(Images/search_box.jpg); background-repeat: no-repeat;
    padding:5px 10px 5px 10px;   /*create the space to show the background image*/
    }
    
    #search_div img{
    height:30px; /*images and controls in div need to be the same height*/
    float:left;
    }
    #search_div select{ /*the drop down control - you could use #id if needed*/
    height:30px; 
    width:100px;
    float:left;
    }
    
    #search_div input{ /*the textbox control - #id if needed*/
    height:30px; 
    width:100px;
    float:left;
    }
    <style>
    
    <div id="search_div">
    
       <img src="url to the magnifying glass image">
    
       <asp:DropDownList ID="DropDownList1" runat="server" Width="120px" BackColor="Transparent" CssClass="obj_nolayout">
                                    <asp:ListItem>Delivery No</asp:ListItem>
                                    <asp:ListItem>LPO No</asp:ListItem>
                                    <asp:ListItem>Supplier</asp:ListItem>
                                    <asp:ListItem>LPO Details</asp:ListItem>
                                    </asp:DropDownList>
    
       <asp:TextBox ID="TextBox1" runat="server">
       <asp:ImageButton ID="ImageButton1" runat="server">
    </div>
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: aligning controls

    hey, This my first attempt to create search box though and i do not have enough idea how mix the box properly.

    what you suggest is to take out search image, asp controls and submit button separately? currently the design was one search image except the asp control (with green arrow controls).

    i see your point when i play around with the codes. the bottom lines seems to play with padding and yes the height of controls.
    Learn something new every .001 second.

  4. #4
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: aligning controls

    Yes that's it. You just need to line up the images,controls inside the div. The "float:left; on the controls may not be needed, leaving them "inline" could do it. Also you might need to set padding:0; margin:0; on the controls or add a bit of margin to the right on them for spacing ( margin:0 0 0 10px; ) . Lastly getting the width of everything right taking into account margins etc. If the div is 400px - 10px left + 10px right padding = 380px make the control widths add up to this or slightly less.
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: aligning controls

    For more information about how to use "float", you might want to take a look at the following:

    http://css.maxdesign.com.au/floatutorial/

    It is a very detailed explanation of how this can be used.

    Gary

Posting Permissions

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



Click Here to Expand Forum to Full Width