【问题标题】:How can you make the copyright text in a Google Map wrap when the map is small?当地图很小时,如何在谷歌地图中制作版权文本?
【发布时间】:2010-03-16 11:34:22
【问题描述】:

当您在网页上嵌入 Google 地图时,地图中会包含版权文本。

如果嵌入宽度较小的地图,版权文本会延伸到 <div> 之外,而不是在其中的两行中换行。

这是 Google 地图为版权文本插入的 HTML:

<div style="-moz-user-select: none; z-index: 0; position: absolute; right: 3px; bottom: 2px; color: black; font-family: Arial,sans-serif; font-size: 11px; white-space: nowrap; text-align: right;" dir="ltr">
    <span></span>
    <span>Map data &copy;2010  LeadDog Consulting, Europa Technologies - </span>
    <a href="http://www.google.com/intl/en_ALL/help/terms_maps.html" target="_blank" class="gmnoprint terms-of-use-link" style="color: rgb(119, 119, 204);">Terms of Use</a>
    <span></span>
</div>

我尝试使用 jQuery 根据其内容(使用:contains())选择此 HTML 并设置不同的样式,但在 IE 8 中没有应用任何样式。它们在 IE 7 和 Firefox 中应用得很好。

$('.map_placeholder div:contains("Map data ")').css({'white-space': 'normal', 'margin-left': '70px', 'width': '210px', 'border-top': 'solid 10px #c00'});
  • 知道 IE 8 是怎么回事吗?
  • 您知道达到相同结果的其他方法吗?

【问题讨论】:

  • 添加您应用的代码和样式?

标签: javascript jquery css google-maps internet-explorer-8


【解决方案1】:
div span { white-space: normal;}

【讨论】:

  • 啊,是的:这是我试图在 IE 8 中应用的样式,但似乎没有一个样式生效。
  • 噢,抱歉:我还在用 JavaScript 术语思考。只需将其粘贴在样式表中,这就是您所说的,就可以了。我已经为地图制定了更具体的规则,但除此之外,这是正确的。
【解决方案2】:

您应该能够在外部div 上设置overflow:hidden,并且没有任何东西会延伸到其框之外。

我会小心删除/设置版权文本的样式,因为这可能违反了 Google 的服务条款。

【讨论】:

  • 使用 white-space: normal 方法,整个文本将(可能,取决于大小)在地图中可见。但是,我同意 DisgruntledGoat,请阅读 TOS。
  • 是的,我确实在寻找可见的版权文本——即使除了 TOS 问题,如果它被剪掉,它看起来仍然很糟糕。
【解决方案3】:

刚刚测试过,它可以工作。用以下内容覆盖内联 css:

div[style]{
 font-size: inherit !important;
 white-space: inherit !important;
}


span[style]{
 white-space: inherit !important;
}

a[style]{
 color: inherit !important;
}

span { white-space: normal; }

【讨论】:

  • 啊,是的:在这种情况下,只有最后一行可以做到。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-21
  • 1970-01-01
  • 2010-10-01
  • 2015-05-29
  • 2014-02-04
  • 1970-01-01
  • 2013-01-18
相关资源
最近更新 更多