Bram's Dev Blog

home

100 Days of Code Day 20 report - CSS fixes

08 Sep 2018

CSS Fix one: make navbar white blue, and then fade to white

My colleague Yana pointed out that the contrast between the navbar and the background is not high enough, making the nav bar hard to read. The theme has a feature that fades the background colour of the navbar to dark blue, while keeping the font the same.

I tried to learn how that fading works, and if I can apply the same to the font, making it fade from blue to white.

Two things are happening:

  .navbar-custom {
    padding: 20px 0;
    border-bottom: none;
    letter-spacing: 1px;
    background: transparent;
    -webkit-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
    -moz-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
    transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
  }
  .navbar-custom.top-nav-collapse {
    padding: 0;
    background: #005989;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  }

When I deactivate the transitions, the background colour changes is sudden, so it has nothing to do with the adding of the extra class element.

The adding of the extra class element happens in a custom piece of javascript that calls on jquery.

$(window).scroll(function() {
    if ($(".navbar").offset().top > 50) {
        $(".navbar-fixed-top").addClass("top-nav-collapse");
    } else {
        $(".navbar-fixed-top").removeClass("top-nav-collapse");
    }
});

I added a nav-transition class to the links I wanted to target, and an additional class that I want added and removed, top-nav-collapse font.

$(window).scroll(function() {
    if ($(".navbar").offset().top > 50) {
        $(".navbar-fixed-top").addClass("top-nav-collapse");
        $(".nav-transition").addClass("top-nav-collapse-font");
    } else {
        $(".navbar-fixed-top").removeClass("top-nav-collapse");
        $(".nav-transition").removeClass("top-nav-collapse-font");
    }
});

So far so good: I can see in inspect element that the class gets added and removed where I want. However, I am currently not able yet to get the css selector right

.navbar-custom a {
  color: #005989;
}
.navbar-custom.top-nav-collapse-font a {
  color: white;
}

Whatever I have tried so far, the .navbar-custom a rule seems all powerful and I’m not able to correctly tie the white color to links that have the top-nav-collapse-font class.

Day 21 Plan

Fresh up my knowledge of css selectors by going through the fabulous CSS Diner again.

Future days - Analyzer.atmire.com work

Future Days - other ideas

  1. Switch to a different project: start working on DSpace 7 Angular
  2. Setup IDEA so I can start editing these blogposts from there, instead of in a text editor
  3. Developer productivity: Get my IntelliJ IDEA Shortcuts in order (CMD+1, CMD+/, …)

Future Days - Atmire.com work

Investigate and work on search engine optimization (SEO) for the main atmire.com website.

Sustainability - Raising the stakes - Looking for sponsors

I have raised the stakes by

This way, every day would be a win. These are the rules that I’ll apply:

  1. I can anticipate or fix a lost day by doing an hour extra the day before, or an hour extra the day after. In theory this means I can maximally compensate a streak of 2 missed days.
  2. Goal is to have a steady frequency, so I can’t just do 8h on a sunday to get myself off the hook for the next 7 days.
  3. Sponsor commitments are fully voluntarily: any sponsor can back out at any time.
  4. My commitment is fully voluntarily: if I want to change the rules or back out, I can at any time.

In September, these are already days that will be very tough:

So that’s already a lot of exposure to potentially missed days.

I will raise the stakes this way and gather money for Charity:Water. Let me know if you want to sponsor me and for how much per completed day in September. September 1st is the first successfully completed day.

September tracking

Will only log the failed days here. No failed days so far.

Thanks to the following sponsors!

  1. Jan & Hilde: €2 per successful day (Yes, these are my parents)