Solved

Need help styling my column two columns of data. I am using CSS with html markup

Posted on 2013-01-14
2
268 Views
Last Modified: 2013-01-15
Hello, I have an Asp.net MVC .form "cshtml". I am using the fieldset command with a little bit of css markup to style the page. The css is only about 6 lines of css markup.

basically I want a label on the left side of my form, followed by a control such as a textbox, middle initial or last name on the right side of the label. Below is a visual representation of what I mean.

First Name               [______________]
Middle Initial           [____]
Last Name                [_______________]
Phone                       [_______________]

Something is terribly wrong though, because the left most column data is not wide enough, and the labels are being broken and printed on the next line. Can someone tell me how to fix my CSS so that I get left and right column data, with the columns aligned? I tried to increase the left most column, by setting the "width" attribute. Below is the CSS I am using. Attached is my markup of my web form, which I am trying to style. I would really appreciate some help.

 .fixwidthlabelLeft
{
    margin: 5px;
    height: 20px;
    width: 150px;
    float:left;
}
cshtmlCode.txt
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 50 total points
ID: 38777099
hi

try to create a table like this
<table>
<tr>
<td width="20%">your text</td>
<td align="left"> your field</td>
</tr>


 

 
 
</table>
0
 
LVL 30

Assisted Solution

by:LZ1
LZ1 earned 230 total points
ID: 38778486
You can use a table. You could also use just CSS.

Try this:
p{float:left;clear:both;}
.fixwidthlabelLeft
{
    margin: 5px;
    height: 20px;
    /*width: 150px;*/
    float:left;
} 
input{float:right;clear:right;margin-left:20px;}

Open in new window

0

Featured Post

Industry Leaders: 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

Suggested Solutions

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
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... …
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
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 …

756 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