Customize Print Link

Hi there, I’m looking to see if anyone know how to customize the print link insteadd of using link text, I’d like to have it be a button so my user can find it easier.

Also, wondering if anyone knows how to modify the … you are logged in as “user name” manage account, log out to remove it from the mobile view only. It’s taking a large chunk out of the top of my mobile page.

Hi Kim,

This will turn the print link into a button.

Add this to your Custom JavaScript:

$(document).on('knack-scene-render.any', function(event, scene) {
  const printLink = $('.kn-print') 
  const printLinkA = $('.kn-print a') 
  const hasPrintLink = $('.kn-print').length

  if (hasPrintLink) {
    printLink.addClass('kn-button position-relative')
    printLinkA.addClass('stretched-link no-underline')
  }
})

Add this to your CSS:

/* Utilities */
.position-relative {
  position: relative;
}

.no-underline {
  text-decoration: none !important;
}

/* Make a link's parent element clickable */
.stretched-link::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: auto;
  content: "";
  background-color: rgba(0, 0, 0, 0);
}

About your second question, can you share a screenshot? Mobile view usually hides the “logged in as user name” text.

Thanks,
Ian
Knack Pros

1 Like

This is so awesome! Thank you :smiley: :smiley:

1 Like

I have a customized layout that someone wrote code for me, so perhaps I just need to modify my code to tell it not to show the user info on the mobile version?

Here’s my full CSS

 
#kn-scene_3 .view_9 {
   float: left;
}

.kn-content h1 {
   color: #000000;
   font-size: 40px;
   font-weight: 05;
}
/*==================STICKY HEADERS========================*/
thead {
  position:sticky;
  top:0px;
  z-index:5;
}
/* Repeat  for each table you want a Sticky Header   */
#view_3349 .kn-table-wrapper {
max-height: 700px;
}
/*======END========STICKY HEADERS======END================*/




/* Doc setup */

html {height: 5%}
body {height: 100%}
#knack-dist_1 {height: 100%; padding: 0 0 0 0; }

#kn-scene_1202  > div.kn-view.kn-info.clearfix > span > a {
  font: bold 20px Arial;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  border-radius: 5px;
}
/* ========== Move Navigation to left - Sidebar ========== */


/* Make crumbtrail visible right away */

.kn-info .kn-crumbtrail {
    visibility: visible !important;
}

/* Blue bar */

.topBar {
  width: 100%;
  background: #07467c;
  height: 64px;
  z-index: 2;
  position: fixed;
  display: none;
}

/* Sidebar animation */

#kn-app-header, .kn-scene, .kn-info {
  transition: margin 500ms, left 500ms;
}

/* Main style changes, only do in tablet version and bigger */

@media only screen and (min-width: 767px) {
  
  #knack-body #kn-app-header {
      background-color: #f5f5f5;
      box-shadow: 1px 1px 30px rgba(0,0,0,0.2)
  }

  .topBar {
    display: block;
  }

  #kn-app-header{
    position: fixed;
    height: 100%;
    left: 0;
    top: 0;
    width: 250px;
    padding-top: 156px;
  }

  #knack-body .kn-scenes .kn-container.kn-scene {
    margin-left: 300px;
    padding-top: 122px;
  }

  #knack-body .kn-container.kn-info, .kn-content .kn-container.kn-info {
    margin-left: 252px;
  }

  .kn-info-bar {
    position: fixed;
    top: 64px;
    width: 100%;
    z-index: 1;
    background: #eee;
    margin-top: 10px;
  }

  #knack-body #kn-app-header .kn-container {
    margin: 0;
  }

  /* Logo stuff */

  .topBar #knack-logo {
    text-align: center;
  }

  .topBar #knack-logo img {
    height: 100px;
    width: auto;
  }

  .topBar #knack-logo {
    position: fixed;
    z-index: 10000000;
    top: 0px;
    left: 80px;
  }

  #kn-app-mobile-container #knack-logo {
    display: none !important;
  }

}

/* Individual Menu Items */

.kn-navigation-bar a {
    background-color: #000000;
    border-radius: 0px !important;
}

#kn-app-menu a span, .kn-info-bar a span {
    color: #07467c;
    font-size: 14px !important;
}

#app-menu-list li{
  width:100%;
}

#app-menu-list li a {
  padding: 8px 10px !important;
}

.kn-content .kn-navigation-bar i.fa {
  width: 20px;
  color: #07467c !important;
}

/* Individual Menu Items - Active, Hover */

/* First, reset the stock knack css */
.kn-navigation-bar .is-active a {
    background-color: transparent !important;
}

.kn-navigation-bar .is-active > a {
    background-color: #eee !important;
}

.kn-navigation-bar a:hover span, .kn-navigation-bar a:hover i:before, .kn-navigation-bar a:hover {
    background-color: #eee !important;
}

/* Hide "Desktop Hamburger" and "Welcome Kim Dion" on mobile. */

@media screen and (max-width: 668px) {
  #kn-app-header .kn-current_user {
    display: none;
  }
  .hideMenuButton {
    display: none;
  }
  #knack-logo img {
    width: 80px;
    height: auto;
  }
}

/* "Desktop Hamburger" button (generated by JS on page load) */

.hideMenuButton {
  position: fixed;
  top: 15px;
  left: 15px;
  font-size: 28px;
  z-index: 1;
  cursor: pointer;
  color: white;
  
}

.hideMenuButton i {
  transition: all .4s linear;
}

.hideMenuButton.rotated i {
  transform: rotate(180deg);
}

/* "Welcome Kim Dion" */

#kn-app-header .kn-current_user {
  text-align: center;
  font-size: 16px;
  margin: 10px 0px;
  color: gray;
  border-bottom: 1px solid #ccc;
  padding-bottom: 15px;
}

#kn-app-header .kn-current_user i { 
  font-size: 16px;
}

/* Misc stuff */

header .kn-container {
  height: 100%;
}

html,body, .kn-content { 
  height: 100%; 
}

.kn-content {
  position: relative;
}



/*defining buttons*/



.blueButton {
    background:    #2d6bb3;
    border:        0px solid #2d6bb3;
    border-radius: 4px;
    padding:       10px 30px;
    color:         #ffffff;
    display:       inline-block;
    font:          normal 600 14px/1 "Calibri", sans-serif;
    text-align:    center;
    text-shadow:   none;
}
.blueButton:hover {
    background:    #4689c0;
}


.greyButton {
    background:    #a3a3a3;
    border:        0px solid #2d6bb3;
    border-radius: 4px;
    padding:       10px 30px;
    color:         #ffffff;
    display:       inline-block;
    font:          normal 600 14px/1 "Calibri", sans-serif;
    text-align:    center;
    text-shadow:   none;
}
.greyButton:hover {
    background:    #C6C6C6;
}

.greenButton {
    background:    #197849;
    border:        0px solid #2d6bb3;
    border-radius: 4px;
    padding:       10px 30px;
    color:         #ffffff;
    display:       inline-block;
    font:          normal 600 14px/1 "Calibri", sans-serif;
    text-align:    center;
    text-shadow:   none;
}
.greenButton:hover {
    background:    #219c5e;
}


/* Add a black background color to the top navigation */
.topnav {
  background-color: #333;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Add an active class to highlight the current page */


/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */
.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
  font-size: 17px; 
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

/* Style the links inside the dropdown */
.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
  display: block;
}

/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
@media screen and (max-width: 600px) {
  .topnav a:not(:first-child), .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}


/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {float: none;}
  .topnav.responsive .dropdown-content {position: relative;}
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}
/* Utilities */
.position-relative {
  position: relative;
}

.no-underline {
  text-decoration: none !important;
}

/* Make a link's parent element clickable */
.stretched-link::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: auto;
  content: "";
  background-color: rgba(0, 0, 0, 0);
}