html - CSS: Two Logos aligned to the left and to the right which should autoscale by window resize -
i have 2 logos on website should go on top of website. 1 logo should aligned left , second logo right. when browser window gets pushed smaller, space in between 2 logos should narrower , when 2 logos "hit" each other, both supposed scale smaller without breaking line.
right left logo scales down , right logo breaks line , gets pushed lower without scaling down @ all.
can me?
my css:
.image-wrapper { position: relative; white-space: nowrap; } .scale-image { display: block; width: auto; max-width: 55%; white-space: nowrap;
}
here html code:
<div class="image-wrapper"> <a href="#" ><img src="http://www.drogies-test.de/wp-content/uploads/2016/05/logo_oskar.jpg" align="left" class="scale-image"/></a> <div /> <div class="image-wrapper"> <a href="#" target="_blank" ><img src="http://www.drogies-test.de/pics/logo_theater_os.gif" align="right" class="scale-image"/></a> <div />
example link: http://www.drogies-test.de/header_show.html
i've adjusted mark-up structure nest elements correctly.
.image-wrapper:first-of-type,.image-wrapper:nth-child(1) { float: left; } .image-wrapper:last-of-type,.image-wrapper:nth-child(2) { float: right; } .image-wrapper { max-width: 50%; } .scale-image { width: 100%; height: auto; }
<body> <div class="image-wrapper"> <a href="http://www.drogies-test.de/"><img src="http://www.drogies-test.de/wp-content/uploads/2016/05/logo_oskar.jpg" align="left" class="scale-image"></a> </div> <div class="image-wrapper"> <a href="http://www.theater-osnabrueck.de/" target="_blank"><img src="http://www.drogies-test.de/pics/logo_theater_os.gif" align="right" class="scale-image"></a> </div> </body>
here's flex
solution:
.image-wrapper { max-width: 50%; } .scale-image { width: 100%; height: auto; } .flex-wrapper { display: flex; justify-content: space-between; }
<div class="flex-wrapper"> <div class="image-wrapper"> <a href="http://www.drogies-test.de/"><img src="http://www.drogies-test.de/wp-content/uploads/2016/05/logo_oskar.jpg" align="left" class="scale-image"></a> </div> <div class="image-wrapper"> <a href="http://www.theater-osnabrueck.de/" target="_blank"><img src="http://www.drogies-test.de/pics/logo_theater_os.gif" align="right" class="scale-image"></a> </div> </div>
note flex not supported in legacy browsers ie 8 , 9, , older versions of webkit browsers safari , firefox (a deprecated or hybrid syntax variation supported instead).
learn more: caniuse.com