As you are probably already aware, you'll need javascript for this to work as intended, and using jQuery's .parent()
ref. method would probably be the most straight forward route to getting there.
Ref: .parent() | jQuery API Documentation
Consider the below:
jQuery('.gm-style-iw').parent().css('width','220px');
On inspecting the element, you will notice that the inline width
property has been applied and is over-qualifying the external width
property rule set be the selector .parent
.
Code Snippet Demonstration:
jQuery('.gm-style-iw').parent().css('width','220px');
.parent {
width: 100%;
background: #dadada;
padding: 5px;
border: 1px dashed;
box-sizing: border-box;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent">
<div class="gm-style-iw"><code>gm-style-iw</code></div>
</div>
It may be better practice to consider applying a class to these elements instead. As demonstrated above, inline style rules are quite persistent and are tricky to over-qualify without depending too much on the !important
declaration.
Consider the following:
jQuery('.gm-style-iw').parent().addClass('contians-child');
Using a class selector as your identifier, you can circumvent this issue which may be sparing you some grey hairs down the line or wasted hours further on into your build.
Code Snippet Demonstration:
jQuery('.gm-style-iw').parent().addClass('contians-child');
.parent {
width: 100%;
background: #dadada;
padding: 5px;
border: 1px dashed;
box-sizing: border-box;
}
.parent.contians-child {
width: 220px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent">
<div class="gm-style-iw"><code>gm-style-iw</code></div>
</div>