Search code examples
htmlcssbulmakotlin-js

Not able to set max-height in css for navbar logo


Am trying to create navbar with logo but unable to increase the size of image.

This is written in kotlin/js but concept should be same for native html/js code.

Html index file:

fun HTML.index() {
  head {
    title("Welcome to Seller Service")
    link(rel = "stylesheet", href = "https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.css") { }
    link(rel = "stylesheet", href = "static/styles/index.css") {}
  }
  body {
    div {
      id = "index"
    }
    script(src = "/static/output.js") {}
    script(src = "https://use.fontawesome.com/releases/v5.3.1/js/all.js") {}
  }
}

React kotlin/js code to replace div with index id:

  override fun RBuilder.render() {
    div(classes = "section") {
      div(classes = "container") {
        nav(classes = "navbar") {
          div(classes = "navbar-brand"){
            a(classes = "navbar-item"){
              img(classes = "img-style", src = "static/images/logo-text.png", alt = "Site logo") {
              }
            }
          }
        }
      }
    }
  }
}

css seen from console in browser:

.navbar-item img {
    max-height:1.75rem
}

.img-style {
    <strike>max-height:4rem;</strike>
}

max-height:4rem; my max-height is not applied, any idea why?


Solution

  • It is overall governed by order of properties. I solved this problem by overriding the same rule in my css and linking it to the page.

    .navbar-item > img { max-height: 4rem; }

    I override this rule of navbar-item class direct children img.