views:

132

answers:

2

My problem is that in some screen resolutions the list items are not in the center of the div while the ul is centered. Does anyone know a solution?
Thanks!

<ul class="news-grid">
<li></li>
<li></li>
</ul>
    $(function() {
              $('#buttons a').click(function(e) {
              $.get( $(this).attr('href'), function(data) {
                 $('.news-grid').quicksand( $(data).find('li'), {adjustHeight: 'dynamic'} );
              }); 
              e.preventDefault(); 
             });
     });
.news-grid {
  overflow: hidden;
  margin: 0px;
  padding-left: 0px;
  width:100%;
  line-height:1.4em;
}

.news-grid:after {
  content: "";
  display: block;
  height: 0;
  overflow: hidden;
  clear: both;
}

.news-grid li {
  display: block;
  float: left;
  width:217px;
  text-align: left;
  line-height: 17px;
  color: #686f74;
  height: 268px;
  overflow: hidden;
  background:url(../images/item_png8.png) no-repeat top left;
  margin:0px 0px 20px 30px;
}
A: 

Hi,

I'm no expert when it comes to HTML and CSS but i guess you could begin to check those points :

  1. Is there any ResetCss sheet called before your code ?
  2. What is the browser that gives you this display ?
  3. Have you tried "margin: auto;" in the "li" class definition ?
Maskime
This isn't a css problem because the specific script calculates the available width and displays as items can fit.For example if the available width is 800px and each item is 200px the script displays 4 items per row but if each item is 210px it displays 3 items and there is a blank space in the right of 170px.What i want to do is to center this 3 items in the center.
Nikos
Can you add your full html so we can see a better representation of what it will look like?
ryanulit
I uploaded here http://sportfeed.nikosk.com/ thanks!
Nikos
A: 

You can do this pretty easily by using this css (assuming you have a reset to clear the margins, paddings and list-style of the ul/li). By setting display to inline and not setting a width, each li will be centered by the ul text-align: center and should space relatively evenly because of the right margin.

#news-grid
{
  overflow: hidden;
  text-align: center;
  width: 100%;
  /* whatever other specific styles you want */  
}

#news-grid li
{
  display: inline;
  margin-right: 2%;
  /* whatever other specific styles you want */
}
ryanulit
I tried your solution but if i don't set width to li elements each element takes the width of the whole ul...
Nikos
Finally I re-think your solution and I figured out that if I set a fixed width size of li and set display:inline-table I finally got what I was looking forward!!
Nikos