jQuery Mobile listview边框半径和边框

jQuery Mobile listview边框半径和边框,jquery,jquery-mobile,border,css,Jquery,Jquery Mobile,Border,Css,如果我在listview中为缩略图设置边框半径和边框,它似乎将边框视为图片的一部分,如下所示: 我使用的CSS覆盖规则如下: .ui-li-thumb { width: 50px; height: 50px; margin: 8px; border: 2px solid #333 !important; border-radius: 10px !important; } 如何使图像也具有边框半径,使其不与边框重叠?您当前无法将“边框半径”应用于图像,这

如果我在listview中为缩略图设置边框半径和边框,它似乎将边框视为图片的一部分,如下所示:

我使用的CSS覆盖规则如下:

.ui-li-thumb {
    width: 50px;
    height: 50px;
    margin: 8px;
    border: 2px solid #333 !important;
    border-radius: 10px !important;
}

如何使图像也具有边框半径,使其不与边框重叠?

您当前无法将“边框半径”应用于图像,这非常糟糕。您需要做的是将其设置为具有边框半径的div的背景,以使其工作。

您当前无法将边框半径应用于图像,这真的很糟糕。您需要做的是将其设置为具有边框半径的div的背景,以使其正常工作。

决定展开上面的评论,并向您展示如何使用JavaScript将图像动态更改为背景图像:

$('li').each(function(index) {

    // Find thumbnail image
    var thumb = $(this).find('img');  

    // Get the src
    var thumbsrc = thumb.attr('src');

    // Insert a span (absolutely positioned using below css)
    thumb.after('<span class="thumbnail" />');

    // Apply our thumbnail as a background image to the span
    $(this).find('span.thumbnail').css("background-image", 'url(' + thumbsrc + ')'); 

    // remove thumbnail image
    $(this).find('img').remove();
});  
JavaScript:

$('li').each(function(index) {

    // Find thumbnail image
    var thumb = $(this).find('img');  

    // Get the src
    var thumbsrc = thumb.attr('src');

    // Insert a span (absolutely positioned using below css)
    thumb.after('<span class="thumbnail" />');

    // Apply our thumbnail as a background image to the span
    $(this).find('span.thumbnail').css("background-image", 'url(' + thumbsrc + ')'); 

    // remove thumbnail image
    $(this).find('img').remove();
});  
工作示例:


决定展开我上面的评论,向您展示如何使用JavaScript将图像动态更改为背景图像:

$('li').each(function(index) {

    // Find thumbnail image
    var thumb = $(this).find('img');  

    // Get the src
    var thumbsrc = thumb.attr('src');

    // Insert a span (absolutely positioned using below css)
    thumb.after('<span class="thumbnail" />');

    // Apply our thumbnail as a background image to the span
    $(this).find('span.thumbnail').css("background-image", 'url(' + thumbsrc + ')'); 

    // remove thumbnail image
    $(this).find('img').remove();
});  
JavaScript:

$('li').each(function(index) {

    // Find thumbnail image
    var thumb = $(this).find('img');  

    // Get the src
    var thumbsrc = thumb.attr('src');

    // Insert a span (absolutely positioned using below css)
    thumb.after('<span class="thumbnail" />');

    // Apply our thumbnail as a background image to the span
    $(this).find('span.thumbnail').css("background-image", 'url(' + thumbsrc + ')'); 

    // remove thumbnail image
    $(this).find('img').remove();
});  
工作示例:


不确定它与jQuery Mobiles标记的配合效果如何,但您甚至可以动态完成。在DOM中搜索图像,删除它们,然后使用jQuery将它们作为背景图像重新应用到最近的范围。不确定它与jQuery Mobiles标记配合得如何,但您甚至可以动态执行。在DOM中搜索图像,删除它们,然后使用jQuery将它们作为背景图像重新应用到最近的范围(否则右侧的文本将移动到图像下方)。谢谢:)酷,是的,可能会有点不同,取决于你的个人设置。如果你把JS的最后一行改成
thumb.hide()(否则右侧的文本将移动到图像下方)。谢谢:)酷,是的,可能会有点不同,取决于您的个人设置。