Javascript 为什么在chrome的“我的地图信息”窗口中会出现滚动条?
下面是JavaScript:Javascript 为什么在chrome的“我的地图信息”窗口中会出现滚动条?,javascript,google-maps,browser,Javascript,Google Maps,Browser,下面是JavaScript: $(document).ready(function(){ //set location of san antonio var san_antonio = new google.maps.LatLng(29.4, -98.544); //set infowindow var infoWindow; //object literal containing the properties var options = { zoom: 9, center: s
$(document).ready(function(){
//set location of san antonio
var san_antonio = new google.maps.LatLng(29.4, -98.544);
//set infowindow
var infoWindow;
//object literal containing the properties
var options = {
zoom: 9,
center: san_antonio,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//create the map
var map = new google.maps.Map(document.getElementById('map'), options);
//create marker
var marker = new google.maps.Marker({
position: san_antonio,
map:map,
title: "san antonio"
});
//add 'click' event listener
google.maps.event.addListener(marker, 'click', function(){
//creates infowindow if it already doesn't exist
if (!infoWindow){
infoWindow = new google.maps.InfoWindow();
}
//create content for infowindow
var content = '<div id="information">'+'<img src="http://a1.twimg.com/profile_images/1549555880/Screenshot.png"/>'+'</div>'
//set content of the infowindow.
infoWindow.setContent(content);
//open infowindow on click of marker
infoWindow.open(map,marker);
//ends the event listener
});
//ends the DOM loader
});
$(文档).ready(函数(){
//设置圣安东尼奥的位置
var san_antonio=新的google.maps.LatLng(29.4,-98.544);
//设置信息窗口
var信息窗口;
//包含属性的对象文字
变量选项={
缩放:9,
中心:圣安东尼奥,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
//创建地图
var map=new google.maps.map(document.getElementById('map'),options);
//创建标记
var marker=new google.maps.marker({
职位:圣安东尼奥,
地图:地图,
标题:“圣安东尼奥”
});
//添加“单击”事件侦听器
google.maps.event.addListener(标记'click',函数(){
//如果信息窗口不存在,则创建信息窗口
如果(!infoWindow){
infoWindow=new google.maps.infoWindow();
}
//为infowindow创建内容
变量内容=“”+“”+“”
//设置信息窗口的内容。
infoWindow.setContent(content);
//单击标记打开信息窗口
信息窗口。打开(地图、标记);
//结束事件侦听器
});
//结束DOM加载程序
});
在chrome浏览器中,当信息窗口弹出时,我会看到一个不需要的滚动条。如果你看右下角,你会注意到还有一点失真
含铬
在Firefox中,infowindow看起来很棒。昨晚我在台式机上工作时没有这个问题,所以我想我的chrome安装可能在笔记本电脑上坏了。你怎么认为?以下是FireFox中的外观:
在FireFox中
我试着做div#information{overflow:hidden}
,但没有任何改变
然后我尝试了div#information{overflow:hidden;height:500px;background color:green;}
,然后滚动条变长了。
这告诉我infowindow作为自己的div,而“information”div的高度导致infowindow的滚动条变大。
尝试添加此css样式:
div#information{
overflow: hidden;
}
可能是线条高度的问题。这就是我犯错误的原因。见答案#11125793(尼克) 它对我有用对我有用:
line-height:1.35;
overflow:hidden;
white-space:nowrap;
我试过了,但滚动条仍然存在。滚动条似乎不是'information'div的一部分,因为当我更改高度时,滚动条会变长。看起来infowindow就像一个被“信息”分区溢出的分区。我会发布更多的分区,这样你就能明白我的意思。请阅读并尝试:是的,我想我的chrome浏览器是一团糟。我在我的桌面上试过,效果很好。我也在JSFIDLE中尝试了它,它以我想要的方式呈现。另外,没有什么能真正解释阴影和右下角的扭曲。太棒了!我很高兴!虽然添加css类后只是一个缓存问题!这里有一个非常相似的问题:
line-height:1.35;
overflow:hidden;
white-space:nowrap;