Почему в js не работает height:auto?

113
18 декабря 2020, 18:50

Как сделать чтобы высота картинки в блоке была auto? Т.е ширина картинки всегда 100%, а высота блока подстраивалась по пропорциональной высоте картинки.

$(".entry-page .entry-inner").each(function() { 
	$(this).css({ 
		"background-image": "url(" + $(this).find("img").attr("src") + ")", 
		"width": "100%", 
    "height": "200px" // Здесь auto не работает 
	}), $(this).find("img").remove(), $(this).append('<div class="glitch_hover_img"></div><div class="glitch_hover_img"></div><div class="glitch_hover_img"></div><div class="glitch_hover_img"></div><div class="glitch_hover_img"></div>') 
});
.box { 
    width: 200px; 
    min-height: 50px; 
    border: 5px solid green; 
    float: left; 
    margin-right: 10px; 
} 
.responsive-img{ 
    max-width: 100%; 
    height: auto; 
} 
.entry-page { 
	opacity: 1!important; 
}     
.entry-page .entry-inner { 
	margin: 0 auto; 
	position: relative; 
	display: block; 
	background-size: cover; 
	overflow: hidden; 
	background-repeat: no-repeat; 
	background-position: center center; 
	max-width: 100%; 
}     
.glitch_hover_img { 
	position: absolute; 
	top: calc(-1 * 2px); 
	left: calc(-1 * 20px); 
	width: calc(100% + 20px * 2); 
	height: calc(100% + 2px * 2); 
	background-image: inherit; 
	background-repeat: no-repeat; 
	background-position: inherit; 
	background-color: transparent; 
	-webkit-transform: translate3d(0,0,0); 
	transform: translate3d(0,0,0); 
	background-blend-mode: transparent; 
	background-size: cover; 
	opacity: 0; 
} 
 
.release-hover-effect-glitch .entry-release .img-bg { 
	opacity: 1!important; 
	background-size: cover; 
} 
 
.entry-page:hover .glitch_hover_img:nth-child(n+2),.release-hover-effect-glitch .entry-release:hover .glitch_hover_img:nth-child(n+2),.wvc-interactive-link-item a:hover .wvc-ils-item-title .glitch_hover_img:nth-child(n+2) { 
	opacity: 1; 
} 
 
.entry-page:hover .glitch_hover_img:nth-child(2),.release-hover-effect-glitch .entry-release:hover .glitch_hover_img:nth-child(2),.wvc-interactive-link-item a:hover .wvc-ils-item-title .glitch_hover_img:nth-child(2) { 
	-webkit-transform: translate3d(20px,0,0); 
	transform: translate3d(20px,0,0); 
	-webkit-animation: glitch-anim-1-horizontal 3s infinite linear alternate; 
	animation: glitch-anim-1-horizontal 3s infinite linear alternate; 
} 
 
.entry-page:hover .glitch_hover_img:nth-child(3),.release-hover-effect-glitch .entry-release:hover .glitch_hover_img:nth-child(3),.wvc-interactive-link-item a:hover .wvc-ils-item-title .glitch_hover_img:nth-child(3) { 
	-webkit-transform: translate3d(calc(-1 * 20px),0,0); 
	transform: translate3d(calc(-1 * 20px),0,0); 
	-webkit-animation: glitch-anim-2-horizontal 3s infinite linear alternate; 
	animation: glitch-anim-2-horizontal 3s infinite linear alternate; 
} 
 
.entry-page:hover .glitch_hover_img:nth-child(4),.release-hover-effect-glitch .entry-release:hover .glitch_hover_img:nth-child(4),.wvc-interactive-link-item a:hover .wvc-ils-item-title .glitch_hover_img:nth-child(4) { 
	-webkit-transform: translate3d(0,calc(-1 * 2px),0) scale3d(-1,-1,1); 
	transform: translate3d(0,calc(-1 * 2px),0) scale3d(-1,-1,1); 
	-webkit-animation: glitch-anim-3-horizontal 3s infinite linear alternate; 
	animation: glitch-anim-3-horizontal 3s infinite linear alternate; 
} 
 
.entry-page:hover .glitch_hover_img:nth-child(5),.release-hover-effect-glitch .entry-release:hover .glitch_hover_img:nth-child(5),.wvc-interactive-link-item a:hover .wvc-ils-item-title .glitch_hover_img:nth-child(5) { 
	-webkit-animation: glitch-anim-1-flash .7s steps(1,end) infinite; 
	animation: glitch-anim-1-flash .7s steps(1,end) infinite; 
} 
 
@-webkit-keyframes glitch-anim-1-flash { 
	0% { 
		opacity: .2; 
		-webkit-transform: translate3d(20px,2px,0); 
		transform: translate3d(20px,2px,0); 
	} 
 
	100%,33% { 
		opacity: 0; 
		-webkit-transform: translate3d(0,0,0); 
		transform: translate3d(0,0,0); 
	} 
} 
 
@keyframes glitch-anim-1-flash { 
	0% { 
		opacity: .2; 
		-webkit-transform: translate3d(20px,2px,0); 
		transform: translate3d(20px,2px,0); 
	} 
 
	100%,33% { 
		opacity: 0; 
		-webkit-transform: translate3d(0,0,0); 
		transform: translate3d(0,0,0); 
	} 
} 
 
@-webkit-keyframes glitch-anim-1-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 2%,100% 2%,100% 5%,0 5%); 
		clip-path: polygon(0 2%,100% 2%,100% 5%,0 5%); 
	} 
 
	10% { 
		-webkit-clip-path: polygon(0 15%,100% 15%,100% 15%,0 15%); 
		clip-path: polygon(0 15%,100% 15%,100% 15%,0 15%); 
	} 
 
	20% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 20%,0 20%); 
		clip-path: polygon(0 10%,100% 10%,100% 20%,0 20%); 
	} 
 
	30% { 
		-webkit-clip-path: polygon(0 1%,100% 1%,100% 2%,0 2%); 
		clip-path: polygon(0 1%,100% 1%,100% 2%,0 2%); 
	} 
 
	40% { 
		-webkit-clip-path: polygon(0 33%,100% 33%,100% 33%,0 33%); 
		clip-path: polygon(0 33%,100% 33%,100% 33%,0 33%); 
	} 
 
	50% { 
		-webkit-clip-path: polygon(0 44%,100% 44%,100% 44%,0 44%); 
		clip-path: polygon(0 44%,100% 44%,100% 44%,0 44%); 
	} 
 
	60% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 20%,0 20%); 
		clip-path: polygon(0 50%,100% 50%,100% 20%,0 20%); 
	} 
 
	70% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 70%,0 70%); 
		clip-path: polygon(0 70%,100% 70%,100% 70%,0 70%); 
	} 
 
	80% { 
		-webkit-clip-path: polygon(0 80%,100% 80%,100% 80%,0 80%); 
		clip-path: polygon(0 80%,100% 80%,100% 80%,0 80%); 
	} 
 
	90% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 55%,0 55%); 
		clip-path: polygon(0 50%,100% 50%,100% 55%,0 55%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 80%,0 80%); 
		clip-path: polygon(0 70%,100% 70%,100% 80%,0 80%); 
	} 
} 
 
@keyframes glitch-anim-1-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 2%,100% 2%,100% 5%,0 5%); 
		clip-path: polygon(0 2%,100% 2%,100% 5%,0 5%); 
	} 
 
	10% { 
		-webkit-clip-path: polygon(0 15%,100% 15%,100% 15%,0 15%); 
		clip-path: polygon(0 15%,100% 15%,100% 15%,0 15%); 
	} 
 
	20% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 20%,0 20%); 
		clip-path: polygon(0 10%,100% 10%,100% 20%,0 20%); 
	} 
 
	30% { 
		-webkit-clip-path: polygon(0 1%,100% 1%,100% 2%,0 2%); 
		clip-path: polygon(0 1%,100% 1%,100% 2%,0 2%); 
	} 
 
	40% { 
		-webkit-clip-path: polygon(0 33%,100% 33%,100% 33%,0 33%); 
		clip-path: polygon(0 33%,100% 33%,100% 33%,0 33%); 
	} 
 
	50% { 
		-webkit-clip-path: polygon(0 44%,100% 44%,100% 44%,0 44%); 
		clip-path: polygon(0 44%,100% 44%,100% 44%,0 44%); 
	} 
 
	60% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 20%,0 20%); 
		clip-path: polygon(0 50%,100% 50%,100% 20%,0 20%); 
	} 
 
	70% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 70%,0 70%); 
		clip-path: polygon(0 70%,100% 70%,100% 70%,0 70%); 
	} 
 
	80% { 
		-webkit-clip-path: polygon(0 80%,100% 80%,100% 80%,0 80%); 
		clip-path: polygon(0 80%,100% 80%,100% 80%,0 80%); 
	} 
 
	90% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 55%,0 55%); 
		clip-path: polygon(0 50%,100% 50%,100% 55%,0 55%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 80%,0 80%); 
		clip-path: polygon(0 70%,100% 70%,100% 80%,0 80%); 
	} 
} 
 
@-webkit-keyframes glitch-anim-2-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 25%,100% 25%,100% 30%,0 30%); 
		clip-path: polygon(0 25%,100% 25%,100% 30%,0 30%); 
	} 
 
	15% { 
		-webkit-clip-path: polygon(0 3%,100% 3%,100% 3%,0 3%); 
		clip-path: polygon(0 3%,100% 3%,100% 3%,0 3%); 
	} 
 
	22% { 
		-webkit-clip-path: polygon(0 5%,100% 5%,100% 20%,0 20%); 
		clip-path: polygon(0 5%,100% 5%,100% 20%,0 20%); 
	} 
 
	31% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
		clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
	} 
 
	45% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 40%,0 40%); 
		clip-path: polygon(0 40%,100% 40%,100% 40%,0 40%); 
	} 
 
	51% { 
		-webkit-clip-path: polygon(0 52%,100% 52%,100% 59%,0 59%); 
		clip-path: polygon(0 52%,100% 52%,100% 59%,0 59%); 
	} 
 
	63% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
		clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
	} 
 
	76% { 
		-webkit-clip-path: polygon(0 75%,100% 75%,100% 75%,0 75%); 
		clip-path: polygon(0 75%,100% 75%,100% 75%,0 75%); 
	} 
 
	81% { 
		-webkit-clip-path: polygon(0 65%,100% 65%,100% 40%,0 40%); 
		clip-path: polygon(0 65%,100% 65%,100% 40%,0 40%); 
	} 
 
	94% { 
		-webkit-clip-path: polygon(0 45%,100% 45%,100% 50%,0 50%); 
		clip-path: polygon(0 45%,100% 45%,100% 50%,0 50%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 14%,100% 14%,100% 33%,0 33%); 
		clip-path: polygon(0 14%,100% 14%,100% 33%,0 33%); 
	} 
} 
 
@keyframes glitch-anim-2-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 25%,100% 25%,100% 30%,0 30%); 
		clip-path: polygon(0 25%,100% 25%,100% 30%,0 30%); 
	} 
 
	15% { 
		-webkit-clip-path: polygon(0 3%,100% 3%,100% 3%,0 3%); 
		clip-path: polygon(0 3%,100% 3%,100% 3%,0 3%); 
	} 
 
	22% { 
		-webkit-clip-path: polygon(0 5%,100% 5%,100% 20%,0 20%); 
		clip-path: polygon(0 5%,100% 5%,100% 20%,0 20%); 
	} 
 
	31% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
		clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
	} 
 
	45% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 40%,0 40%); 
		clip-path: polygon(0 40%,100% 40%,100% 40%,0 40%); 
	} 
 
	51% { 
		-webkit-clip-path: polygon(0 52%,100% 52%,100% 59%,0 59%); 
		clip-path: polygon(0 52%,100% 52%,100% 59%,0 59%); 
	} 
 
	63% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
		clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
	} 
 
	76% { 
		-webkit-clip-path: polygon(0 75%,100% 75%,100% 75%,0 75%); 
		clip-path: polygon(0 75%,100% 75%,100% 75%,0 75%); 
	} 
 
	81% { 
		-webkit-clip-path: polygon(0 65%,100% 65%,100% 40%,0 40%); 
		clip-path: polygon(0 65%,100% 65%,100% 40%,0 40%); 
	} 
 
	94% { 
		-webkit-clip-path: polygon(0 45%,100% 45%,100% 50%,0 50%); 
		clip-path: polygon(0 45%,100% 45%,100% 50%,0 50%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 14%,100% 14%,100% 33%,0 33%); 
		clip-path: polygon(0 14%,100% 14%,100% 33%,0 33%); 
	} 
} 
 
@-webkit-keyframes glitch-anim-3-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 1%,100% 1%,100% 3%,0 3%); 
		clip-path: polygon(0 1%,100% 1%,100% 3%,0 3%); 
	} 
 
	5% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 9%,0 9%); 
		clip-path: polygon(0 10%,100% 10%,100% 9%,0 9%); 
	} 
 
	10% { 
		-webkit-clip-path: polygon(0 5%,100% 5%,100% 6%,0 6%); 
		clip-path: polygon(0 5%,100% 5%,100% 6%,0 6%); 
	} 
 
	25% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
		clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
	} 
 
	27% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 10%,0 10%); 
		clip-path: polygon(0 10%,100% 10%,100% 10%,0 10%); 
	} 
 
	30% { 
		-webkit-clip-path: polygon(0 30%,100% 30%,100% 25%,0 25%); 
		clip-path: polygon(0 30%,100% 30%,100% 25%,0 25%); 
	} 
 
	33% { 
		-webkit-clip-path: polygon(0 15%,100% 15%,100% 16%,0 16%); 
		clip-path: polygon(0 15%,100% 15%,100% 16%,0 16%); 
	} 
 
	37% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 39%,0 39%); 
		clip-path: polygon(0 40%,100% 40%,100% 39%,0 39%); 
	} 
 
	40% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 21%,0 21%); 
		clip-path: polygon(0 20%,100% 20%,100% 21%,0 21%); 
	} 
 
	45% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 55%,0 55%); 
		clip-path: polygon(0 60%,100% 60%,100% 55%,0 55%); 
	} 
 
	50% { 
		-webkit-clip-path: polygon(0 30%,100% 30%,100% 31%,0 31%); 
		clip-path: polygon(0 30%,100% 30%,100% 31%,0 31%); 
	} 
 
	53% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 69%,0 69%); 
		clip-path: polygon(0 70%,100% 70%,100% 69%,0 69%); 
	} 
 
	57% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 41%,0 41%); 
		clip-path: polygon(0 40%,100% 40%,100% 41%,0 41%); 
	} 
 
	60% { 
		-webkit-clip-path: polygon(0 80%,100% 80%,100% 75%,0 75%); 
		clip-path: polygon(0 80%,100% 80%,100% 75%,0 75%); 
	} 
 
	65% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 51%,0 51%); 
		clip-path: polygon(0 50%,100% 50%,100% 51%,0 51%); 
	} 
 
	70% { 
		-webkit-clip-path: polygon(0 90%,100% 90%,100% 90%,0 90%); 
		clip-path: polygon(0 90%,100% 90%,100% 90%,0 90%); 
	} 
 
	73% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
		clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
	} 
 
	80% { 
		-webkit-clip-path: polygon(0 100%,100% 100%,100% 99%,0 99%); 
		clip-path: polygon(0 100%,100% 100%,100% 99%,0 99%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 71%,0 71%); 
		clip-path: polygon(0 70%,100% 70%,100% 71%,0 71%); 
	} 
} 
 
@keyframes glitch-anim-3-horizontal { 
	0% { 
		-webkit-clip-path: polygon(0 1%,100% 1%,100% 3%,0 3%); 
		clip-path: polygon(0 1%,100% 1%,100% 3%,0 3%); 
	} 
 
	5% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 9%,0 9%); 
		clip-path: polygon(0 10%,100% 10%,100% 9%,0 9%); 
	} 
 
	10% { 
		-webkit-clip-path: polygon(0 5%,100% 5%,100% 6%,0 6%); 
		clip-path: polygon(0 5%,100% 5%,100% 6%,0 6%); 
	} 
 
	25% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
		clip-path: polygon(0 20%,100% 20%,100% 20%,0 20%); 
	} 
 
	27% { 
		-webkit-clip-path: polygon(0 10%,100% 10%,100% 10%,0 10%); 
		clip-path: polygon(0 10%,100% 10%,100% 10%,0 10%); 
	} 
 
	30% { 
		-webkit-clip-path: polygon(0 30%,100% 30%,100% 25%,0 25%); 
		clip-path: polygon(0 30%,100% 30%,100% 25%,0 25%); 
	} 
 
	33% { 
		-webkit-clip-path: polygon(0 15%,100% 15%,100% 16%,0 16%); 
		clip-path: polygon(0 15%,100% 15%,100% 16%,0 16%); 
	} 
 
	37% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 39%,0 39%); 
		clip-path: polygon(0 40%,100% 40%,100% 39%,0 39%); 
	} 
 
	40% { 
		-webkit-clip-path: polygon(0 20%,100% 20%,100% 21%,0 21%); 
		clip-path: polygon(0 20%,100% 20%,100% 21%,0 21%); 
	} 
 
	45% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 55%,0 55%); 
		clip-path: polygon(0 60%,100% 60%,100% 55%,0 55%); 
	} 
 
	50% { 
		-webkit-clip-path: polygon(0 30%,100% 30%,100% 31%,0 31%); 
		clip-path: polygon(0 30%,100% 30%,100% 31%,0 31%); 
	} 
 
	53% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 69%,0 69%); 
		clip-path: polygon(0 70%,100% 70%,100% 69%,0 69%); 
	} 
 
	57% { 
		-webkit-clip-path: polygon(0 40%,100% 40%,100% 41%,0 41%); 
		clip-path: polygon(0 40%,100% 40%,100% 41%,0 41%); 
	} 
 
	60% { 
		-webkit-clip-path: polygon(0 80%,100% 80%,100% 75%,0 75%); 
		clip-path: polygon(0 80%,100% 80%,100% 75%,0 75%); 
	} 
 
	65% { 
		-webkit-clip-path: polygon(0 50%,100% 50%,100% 51%,0 51%); 
		clip-path: polygon(0 50%,100% 50%,100% 51%,0 51%); 
	} 
 
	70% { 
		-webkit-clip-path: polygon(0 90%,100% 90%,100% 90%,0 90%); 
		clip-path: polygon(0 90%,100% 90%,100% 90%,0 90%); 
	} 
 
	73% { 
		-webkit-clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
		clip-path: polygon(0 60%,100% 60%,100% 60%,0 60%); 
	} 
 
	80% { 
		-webkit-clip-path: polygon(0 100%,100% 100%,100% 99%,0 99%); 
		clip-path: polygon(0 100%,100% 100%,100% 99%,0 99%); 
	} 
 
	100% { 
		-webkit-clip-path: polygon(0 70%,100% 70%,100% 71%,0 71%); 
		clip-path: polygon(0 70%,100% 70%,100% 71%,0 71%); 
	} 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
<div class="box"> 
<a href="#" class="entry-page"> 
    <span class="entry-inner mySingleImage"> 
        <img src="https://wmpics.pics/di-HTCR.png" class="responsive-img"> 
    </span> 
</a> 
</div>

READ ALSO
Ошибка при взятии json c сервера

Ошибка при взятии json c сервера

Пробую забрать json с сервера для дальнейшей манипуляции и получаю ошибку

125