Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Mobile Listview Thumbnail Alignment

I am using JQuery Mobile listview to create a list of items with thumbnails.

How do I set the alignment for thumbnail images used in Listviews?

I tried setting the style attribute for the image using align, vertical-align or even wrapping the image with a <center> tag but it doesn't work.

I tried margin-top as well but that doesn't work as it would push all thumbs down regardless of its height. I only want to vertically & horizontally centered images that are less than 80 x 80 pixels.

I would like to horizontally and vertically align the image to the center.

like image 434
Mongrel Jedi Avatar asked Nov 17 '11 16:11

Mongrel Jedi


1 Answers

JQuery mobile applies the following styles to your ui-li-icon:

.ui-li-icon {
     position: absolute;
     left: 1px;
     top: 0;
     max-height: 80px;
     max-width: 80px;
 }

To not break the existing implementation, you could wrap you icon image in another tag, for example:

<li>
   <a href="#p1">
         <p class="my_icon_wrapper">
              <img src="images/myicon_image." width="32" height="32"/>
             </p>
        <h3>List item title</h3>
        <p>List item description</p>
   </a>
</li>

The my_icon_wrapper can them implement some of the styles jQuery Mobile did, e.g.:

.my_icon_wrapper {
        float: left; 
        width: 80px; height: 80px;
        text-align: center; 
        vertical-align: middle; 
}

You'd need to play with the styles a bit to obtain the desired effect.

like image 71
Ryan Avatar answered Sep 30 '22 00:09

Ryan