views:

48

answers:

2

Here is my layout,

Summary view

I am using one div and many spans for getting the above view... Look at all the rows ther are not properly aligned...

<div class="resultsdiv"><br />
<span style="width:200px;" class="resultName">' + employee.Emp_Name + '</span>
<span class="resultfields" style="padding-left:100px;">Category&nbsp;:</span>&nbsp;
<span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br />
<span id="SalaryBasis" class="resultfields">Salary Basis&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.SalaryBasis + '</span>
<span class="resultfields" style="padding-left:25px;">Salary&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.FixedSalary + '</span>
<span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address&nbsp;:</span>&nbsp;
<span class="resultfieldvalues">' + employee.Address + '</span>
</div>

and my css are

.resultsdiv
{
    background-color: #FFF;border-top:solid 1px #ddd; height:50px; border-bottom:solid 1px #ddd; padding-bottom:15px; width:450px; 
}
.resultseven { background-color: #EFF1f1; }
.resultshover { background-color: #F4F2F2; cursor:pointer; }

.resultName
{
    font-size:125%;font-weight:bolder;color:#476275;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}
.resultfields
{
    font-size:110%;font-weight:bolder;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}
.resultfieldvalues
{
    color:#476275;font-size:110%;font-weight:bold;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}

Any suggestion to get it aligned properly.... Should i use divs insted of spans to get this properly aligned...

+4  A: 

In my opinion, that is the type of data that should be in a table. It's not layout, it's tabular, repeating data.

Anthony Pegram
I agree. Because you are not adding elements to the data, it would be best to use a table.
Samuel
@samuel and Antony i know it can be done with tables... But i want to use divs..
Pandiya Chendur
it's not actually tabular data. could be considered a borderline case. hold on I'm whipping something up for you.
dasil003
use tables when it is appropriate to use tables
Michael
This is an appropriate use of tables, IMO.
Carson Myers
+2  A: 

Here is a rough cut of some rewritten HTML and CSS. I have not tested this, but it should get you close. Post a screenshot if it doesn't work.

HTML

<div class="resultsdiv">
  <div class="name">' + employee.Emp_Name + '</div>
  <div class="category"><span>Category :</span> ' + employee.Desig_Name + '</div>
  <div class="salary_basis"><span>Salary Basis :</span> ' + employee.SalaryBasis + '</div>
  <div class="salary"><span>Salary :</span> ' + employee.FixedSalary + '</div>
  <div class="address"><span>Address :</span> ' + employee.Address + '</div>
</div>

CSS

.resultsdiv { color: black }
.resultsdiv span { color: #666 }
.resultsdiv { width: 600px}
.resultsdiv div { float: left }
.resultsdiv .name { width: 230px; padding-right 20px; }
.resultsdiv .category { width: 350px }
.resultsdiv .salary_basis { clear: left; width: 180px; padding-right: 20px }
.resultsdiv .salary { width: 180px; padding-right: 20px }
.resultsdiv .address { width: 200px; }
dasil003
@dasil003 that woorked pretty well just edited a few to make mine working...
Pandiya Chendur