Alexandru Alexandru - 1 year ago 201
HTML Question

Stretch image in iron-image element

I have an element inside a div :

<div style="width:330px;"><iron-image src="image.png"></iron-image></div>
The image is 315px in width and 237px height. I want this image to stretch and make it 330px in width as it the container that is inside of, and the height to be auto to do not break the image ratio.

I have tried this :

iron-image {
iron-image img {

And :

<div style="width:330px;"><iron-image src="image.png" style="width:330px;height:auto"></iron-image></div>

How do i make the
<img ... >
element inside the
element stretch to 330px width and automatic height ?

Answer Source

I had the same problem, the sizing attribute doesn't help me for that, and because the img inside iron-image is under shady DOM, you can access it with ::content.

#imgWrapper {
    width: 330px;
iron-image {
iron-image::content img {
    width: 100%;


<div id="imgWrapper">
    <iron-image src="image.png"></iron-image>

for ::content to work in light dom (outside of a custom element) don't forget

<style is="custom-style">

Hope it helps !

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download