Solved

Asp.net - CSS - get controls to align to the left in DIV tag

Posted on 2011-03-23
4
510 Views
Last Modified: 2012-05-11
I have CSS mapping out my columns..but the controls need to align to the left...
div.Delivery_col { float:left;width:26%;border: 1px solid #000; }
.mylabel
{
      
      
}
.mybutton
{
      
      
}

      <div class="Delivery_col">
              <asp:Label ID="Label5" runat="server"></asp:Label>
              <asp:Label ID="Label10" runat="server"></asp:Label>
              <asp:Label ID="Label15" runat="server"></asp:Label>
              <asp:Label ID="Label20" runat="server"></asp:Label>
              <asp:Label ID="Label25" runat="server"></asp:Label>
      
      </div>
0
Comment
Question by:GlobaLevel
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
jkofte earned 500 total points
ID: 35199556
use text-align:left

div.Delivery_col { float:left;width:26%;border: 1px solid #000; text-align:left }
0
 
LVL 17

Expert Comment

by:mreuring
ID: 35199951
Not sure about the rest of the JS/CSS developers, but I for one don't know what the hell <asp:Label ID="Label5" runat="server"></asp:Label> is supposed to render...

Considering the open ended CSS statements it would seem a 'label' and a 'button'? My suggestion would be to rewrite the block using a list/list-items, as that seems to be what your doing semantically, rendering a list of 'items'. While being more correct (in my opinion) it would also make it slightly more convenient to work with.

Of course there's a good chance I don't understand what you actually want :)
ul.Delivery_col { float:left;width:26%;border: 1px solid #000; list-style:none; margin: 0; padding:0; }

Open in new window

<ul class="Delivery_col">
   <li><asp:Label ID="Label5" runat="server"></asp:Label></li>
   <li><asp:Label ID="Label10" runat="server"></asp:Label></li>
   <li><asp:Label ID="Label15" runat="server"></asp:Label></li>
   <li><asp:Label ID="Label20" runat="server"></asp:Label></li>
   <li><asp:Label ID="Label25" runat="server"></asp:Label></li>
</ul>

Open in new window

0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35200158
mreuring..kinda worked...but for textboxes..your idea wont work..as it stacks them diagonally..
      <div class="quanity_col">
               <asp:TextBox ID="TextBox1" runat="server" Width="40px"  CssClass="mybutton"></asp:TextBox><br />
               <asp:TextBox ID="TextBox2" runat="server" Width="40px" CssClass="mybutton"></asp:TextBox><br />
              <asp:TextBox ID="TextBox3" runat="server" Width="40px" CssClass="mybutton"></asp:TextBox><br />
              <asp:TextBox ID="TextBox4" runat="server" Width="40px" CssClass="mybutton"></asp:TextBox><br />
              <asp:TextBox ID="TextBox5" runat="server" Width="40px" CssClass="mybutton"></asp:TextBox><br />
      </div>
0
 
LVL 17

Expert Comment

by:mreuring
ID: 35200341
Again, not a clue what the resulting html looks like, I can only guess why what I proposed doesn't work.

What I proposed is straight-forward. You're displaying a list of 'stuff' (I don't care much about what stuff ;)). So you stick the 'stuff' inside a <li>, and since those aren't allowed to live on their own, you stick the <li> elements in a <ul>. Then you want to put the list of 'stuff' to the left, so you float the <ul> to the left. Case closed.

Diagonal stacking can only occur if some of the 'stuff' is not floating (creating a full-width block) and some of it is (creating a partial block). The quick and dirty way to solve that (following the earlier posted html I proposed) is to 'clear' the floated content:
 
ul.Delivery_col li { clear:left }

Open in new window


I could be wrong, there's always that change, but I know my HTML/CSS pretty damn well, I just don't know much about .Net
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…

910 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

25 Experts available now in Live!

Get 1:1 Help Now