Responsive images in tables (bootstrap 3)

前端 未结 5 1507
失恋的感觉
失恋的感觉 2020-12-15 07:05

I\'m using the Bootstrap 3 Framework and have some troubles with the \"img-responsive\" class in Firefox. I have a 4 column-Table with 15/50/10/25% layout. In the first colu

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 07:46

    Try this code

    $(window).load(function() {
        $('img.img-responsive').each(function(){
            // Remember image size
            var imgWidth = $(this).width();
            // hide image 
            $(this).hide();
            // if container width < image width, we add width:100% for image 
            if ( $(this).parent().width() < imgWidth ) { $(this).css('width', '100%'); }
            // show image
            $(this).show();
        });
    });
    

提交回复
热议问题