Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-23
4
Medium Priority
?
551 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
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…
Suggested Courses

916 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