[英]React google-maps-react, Change property of hidden div from google maps api
So I am rendering some maps using the google-maps-react library. 所以我正在使用google-maps-react库渲染一些地图。 However, I am having an issue with the most outter div which the google maps component produces. 但是,我在使用Google Maps组件产生的最外面的div时遇到问题。 I don't want the div to be larger than its parent div, but its by default set to 100% width+height as well as position absolute(so oveflow:hidden does not work). 我不希望div大于其父div,但默认情况下将其设置为100%的宽度和高度以及位置的绝对值(因此oveflow:hidden不起作用)。 It also does not have a id or class name therefor I cannot grab the div directly. 它也没有ID或类名,因此我无法直接抓取div。
Below is the code to how I have my Map in a return statement for one of my react methods. 以下是我的React方法之一的return语句中如何包含Map的代码。 The style change takes affect for the div BELOW the most outer div, not the one I need to change. 样式更改对最下面的div的div起作用,而不是我需要更改的div。
<Map google={this.props.google} zoom={14} style={{width:'200px',
height:'200px', position:'relative'}}>
<Marker onClick={this.onMarkerClick}
name={'Current location'} />
<InfoWindow onClose={this.onInfoWindowClose}>
<div>
"test"
</div>
</InfoWindow>
</Map>
Below is a snippet of the two most outer divs produced by the google maps react component. 以下是google maps react组件产生的两个最外面的div的片段。 The most outer div is basically invisible and I can't change its style properties 最外面的div基本是不可见的,我无法更改其样式属性
If someone can help me out on how to change that style property to 'position:relative' that would be great! 如果有人可以帮助我解决如何将样式属性更改为“ position:relative”,那就太好了!
you can access inner first div using this css code 您可以使用此CSS代码访问内部first div
.classname div:first-child{
position: relative !important;
}
In your case use like this 在你的情况下使用这样
<div id="mapBox">
<Map google={this.props.google} zoom={14} style={{width:'200px',
height:'200px', position:'relative'}}>
<Marker onClick={this.onMarkerClick}
name={'Current location'} />
<InfoWindow onClose={this.onInfoWindowClose}>
<div>
"test"
</div>
</InfoWindow>
</Map>
</div>
//// css code
#mapBox div:first-child {
position: relative !important;
height: 500px !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.