如何让我的 AdRotator 广告保持在 div 内?

How can I get my AdRotator ads to stay within the div?

我以典型方式(我认为)设置了一个 AdRotator,其中 xml 文件如下:

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>Images\Space3.jpg</ImageUrl>
<NavigateUrl>https://www.amazon.com</NavigateUrl>
</Ad>
<Ad>
<ImageUrl>Images\eatAtJoes.jpg</ImageUrl>
<NavigateUrl>https://www.gutenberg.org</NavigateUrl>
</Ad>
. . .
<Ad>
<ImageUrl>Images\thisSpace4Rent.png</ImageUrl>
<NavigateUrl>https://www.wikipedia.org</NavigateUrl>
</Ad>
</Advertisements>

...我将其添加到我的 html 中,如下所示:

<div class="container">
  <div class="row">
    <div class="col">
      <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/AdRotatorLeft.xml" />
    </div>
. . .

我认为这应该将 AdRotator 图像保留在该列中,但它们会溢出整个页面 - 进入中间列和右列,另外:

images/ads 应保留在黑色矩形内。为什么图像/“广告”会溢出它所在的 div,我如何才能强制它保持在边界内?

更新

当我为超链接更改 AdRotator 时,我遇到了完全相同的问题:

<div class="container">
  <div class="row">
    <div class="col">
      <div class="row">
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="https://www.amazon.com/Still-    Casting-Shadows-Shared-History/dp/0595397247/">
    <asp:image runat="server" ImageUrl="images/EatAtJoesCaptioned.png" /><br />
    <asp:Label runat="server" Text="Some Text"></asp:Label>
    </asp:HyperLink>
      </div>
    </div>
. . .

请分享更多 html 并尝试实现您想要实现的目标。但是根据我的观察,就像你做的 row > col > row 是没用的。只看你先做的。然后修复 img 宽度,你需要添加 类 像:mh-100 mw-100 或:

style="max-width:100%; max-height:100%;"

这样你的图像就会尊重你的容器。

因此,根据您上次的更新,我建议您试试这个:

<div class="container">
  <div class="row">
    <div class="col">
      <div class="row mx-0">
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="https://www.amazon.com/Still-    Casting-Shadows-Shared-History/dp/0595397247/">
    <asp:image style="max-width:100%; max-height:100%;" runat="server" ImageUrl="images/EatAtJoesCaptioned.png" /><br />
    <asp:Label runat="server" Text="Some Text"></asp:Label>
    </asp:HyperLink>
      </div>
    </div>
...............