I'm setting up a new website, and I want to change logo color (that is position: fixed
) depending on background color or image.
An example that I found is on this site. You can look at how the logo and some elements change color depending on background.
body {
margin: 0;
}
.logo img {
position: fixed;
width: 100px;
}
.black {
background: black;
width: 100%;
height: 400px;
}
.yellow {
background: yellow;
width: 100%;
height: 400px;
}
.red {
background: red;
width: 100%;
height: 400px;
}
.imageBg {
background: url(https://images.pexels.com/photos/2208895/pexels-photo-2208895.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260);
width: 100%;
height: 400px;
background-size: cover;
}
<div class="logo">
<img src="http://www.clker.com/cliparts/n/y/a/M/G/h/fdl-logo.svg">
</div>
<!-- change logo color to: black -->
<section class="yellow"></section>
<!-- change logo color to: white -->
<section class="black"></section>
<!-- change logo color to: white -->
<section class="red"></section>
<!-- change logo color to: black -->
<section class="yellow"></section>
<!-- change logo color to: white -->
<section class="imageBg"></section>
Here is my fiddle: https://jsfiddle.net/o0gnayht/