Solved

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

Posted on 2011-03-23
4
533 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery Search Filter 2 67
Google Tag Manager - Add Trigger Using Div class 22 50
How can I make my tabs look like this? 1 29
Json and ajax 1 18
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

680 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