ブートストラップポップオーバーの画像がポップオーバーにあふれています[重複]

Nov 25 2020

ポップオーバーの画像を含むページを作成しようとしています。オンラインでデモを使用して作成しましたが、画像が特定のサイズより大きくなると、ポップオーバーからオーバーフローし始めます。これを修正するにはどうすればよいですか?

Js Fiddleはこちら: https://jsfiddle.net/rdvL6kj9/10/

html:

  <div class="container my-4">
    <p class="font-weight-bold">This simple example shows how to place an image within a bootstrap popover. You can
      define if you want to launch the popover on hover or on click.</p>

    <p><strong>Detailed documentation and more examples of Bootstrap grid you can find in our <a href="https://mdbootstrap.com/docs/jquery/javascript/popovers/"
    target="_blank">Bootstrap Popovers Docs</a></strong></p>

    <a class="btn btn-primary" data-toggle="popover-hover" data-img="https://placekitten.com/500/300">Hover
      over me</a>
  </div>
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

js:

    // popovers initialization - on hover
    $('[data-toggle="popover-hover"]').popover({ html: true, trigger: 'hover', placement: 'bottom', content: function () { return '<img src="' + $(this).data('img') + '" />'; }
    });

これが問題のスクリーンショットです:

回答

1 SaiManoj Nov 25 2020 at 00:43

あなたはほとんどそこにいました。私は>ビルトインクラスのブートストラップを追加したclass="img-fluid"imgすべての画像間で、それが応答にするタグ

   $('[data-toggle="popover-hover"]').popover({ html: true, trigger: 'hover', placement: 'bottom', content: function () { return '<img src="' + $(this).data('img') + '"  class="img-fluid"/>'; }
    });

これが作業中のフィドルです

jmona789 Nov 25 2020 at 01:06

将来この質問に出くわした人のために、答えは次のとおりです。画像を縮小しても問題がない場合は、Sai Manojの答えを使用できます。画像を大きくしたい場合は、max-widthプロパティをオーバーライドする必要があります。このようなポップオーバークラスで:

.popover {
    max-width: none;
}