Topic: Stylesheets ...Queries

<%=stylesheet_link_tag 'application'%>



<%@pending_contacts.each do |f|%>

    <div class="navbar">
    <%@users = Userinfo.find(f.user_id)%>
    <%=check_box_tag 'user',f.id%><%=@users.first_name%></br>
    </div>

    <div class="mavbar">
    <%@contacts = Userinfo.find(f.contact_id)%>
     <%=@contacts.first_name%></br>
    </div>
     
   
   
<%end%>






i want the found results of @users in a left column and @contacts in a left column.
when i use stylesheets for that it makes misalignment because of the looping.Is there any ways to do that..
pls help me........

Re: Stylesheets ...Queries

i want the found results of @users in a left column and @contacts in a left column.

Ok, so to fully understand what you are asking you want the results of all the objects created off of the @users variable in the left column, and the objects of the @contacts in a right column?

And when you said

looping.ls

did you mean looping.js?

I just want to make sure I'm clear so I don't misrepresent anything in my suggestions.

Now, with that said, can you post your stylesheet code, or at least that pertaining to navbar and mavbar (.navbar and .mavbar)? That would definitely help in assessing your issue.

Re: Stylesheets ...Queries

thanks for reply...
that s not js and all.


.navbar
{
  width: 50%;
  float : left;
  text-align: left;
  margin-left:  10%;
 
}

.mavbar
{
  width: 20%;
  float : right;
  margin-right:  20%;
 

 
}

i want the found results of @users in  left column and @contacts in Right column.

Re: Stylesheets ...Queries

Ok, now your CSS logically makes sense, but the issue is different browsers will not render the page correctly as you would prefer. Now looking at your initial syntax, it seems that the results would be shown vertically ascending each other on the page to the left and right.

With that in mind, from my own personal experience, I've found using tables to align such things is much more efficient than solely using divs. Of course, different people will go about things different ways, but that method has always worked best for me. Those kinds of things I will have a div I usually call "main" to represent the entire page, then section out the page as necessary using divs, then inside those divs, I will either add another nested div to that and then use positioning to get the table in a specific place, or just straight up position the table from there.

However if you don't want to go about it that way, thats perfectly fine too. You can achieve the same result using just divs by changing your css to something like:

.navbar
  {
    position:absolute;
    top:    //This is how far you want the divs to be from the top of the page in either pixels (px), inches (in) or percent of course.
    left: 10%;
    text-align: left;
  }

.mavbar
  {
    position: absolute;
    top: <same height as the other div>
    right: 20%;
  }


I have found that the float and margin property only works real well what you are using with those properties is contained in something like a table cell, or another div. Hope this helps. Let me know if you have any questions. smile

Re: Stylesheets ...Queries

newb (lol, hard not to laugh at that tongue)

Firstly, I think your structural markup isn't the best, as it's very easy to have this break, even if you get the CSS right (by someone resizing their browser, when your content doesn't fit, for example).

You're displaying rows of data, which is ideally what (funnily enough) tables are made for. One can over-do style-driven layouts wink

Also, that aside - you may want to look into setting up associations between your models - as what you're doing can be more easily done with your @pending_contacts array, so that each iteration already has the data you need.

Re: Stylesheets ...Queries

Could u explain me how can i do that

Re: Stylesheets ...Queries

in your pending contacts model, setup these associations:

belongs_to :user_info, :class_name => 'UserInfo'
belongs_to :contact, :class_name => 'UserInfo', :conditions => 'contact_id = user_info_id'

hard to know exactly what fields to use, as your structure isn't on this forum, but read up on rails associations, and then read that. That way, when you loop through, you can do something like:

<%@pending_contacts.each do |f|%>
  <%= f.user_info.first_name %>
  <%= f.contact.first_name %>
<% end %>

Hope that helps smile