Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Botom of page is wrong color 5 17
Create tabs to show divs 9 35
How to combine and minify CSS and JS files 5 15
Autocomplete with Jquery Question 2 19
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

790 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