var divElement = document.getElementById("test");
var newImage = new Image();
newImage.onload = function() {
newImage.style.position = "absolute";
newImage.style.left = "0px";
newImage.style.top = "0px";
divElement.appendChild(newImage);
//Reflection
var div = document.createElement('div');
div.className = 'reflection-image';
div.style.width = this.width + 'px';
div.style.height = (this.height * 0.7) + 'px';
div.style.backgroundImage = "url('" + this.src + "')";
div.style.left = "0px";
div.style.top = "400px";
divElement.appendChild(div);
}
newImage.src = "https://3.bp.blogspot.com/-W__wiaHUjwI/Vt3Grd8df0I/AAAAAAAAA78/7xqUNj8ujtY/s400/image02.png";
body {
background-color: white;
}
.reflection-image {
position: absolute;
background: 0 bottom no-repeat;
transform: scaleY(-1);
}
.reflection-image:after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+100&1+0,0.7+100 */
background: -moz-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.7) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.7) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.7) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#b3ffffff', GradientType=0);
/* IE6-9 */
}
<div class="tinted-image" id="test">
</div>
このhttps://jsfiddle.net/iRbouh/paren7ks/を見てみてください! –