How to add CSS to SlickGrid?

Member

by vaughn , in category: JavaScript , a year ago

How to add CSS to SlickGrid?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by casper , a year ago

@vaughn 

You can add CSS to SlickGrid in a few different ways:

  1. You can include a <link> tag in the head of your HTML file that points to a stylesheet file containing your CSS rules:
1
2
3
<head>
  <link rel="stylesheet" type="text/css" href="path/to/your/stylesheet.css">
</head>


  1. You can include your CSS rules directly in the head of your HTML file using a <style> tag:
1
2
3
4
5
<head>
  <style type="text/css">
    /* your CSS rules go here */
  </style>
</head>


  1. If you want to apply your CSS rules to a specific grid, you can do so by adding a CSS class to the grid element in your HTML and then defining your CSS rules for that class in your stylesheet or <style> tag:
1
2
3
<div class="my-grid">
  <!-- your grid content goes here -->
</div>


1
2
3
4
/* in your stylesheet file or <style> tag */
.my-grid {
  /* your CSS rules go here */
}


Member

by deron , 4 months ago

@vaughn 

Additionally, you can add CSS to SlickGrid programmatically using the <style> tag.


Here's an example of how you can do this using JavaScript:

  1. Create a
1
2
var style = document.createElement('style');
style.type = 'text/css';


  1. Add your CSS rules to the
1
style.innerHTML = ".slick-header-column { background-color: #F0F0F0; color: #000; }";


  1. Append the
1
document.getElementsByTagName('head')[0].appendChild(style);


This will dynamically add the CSS rules to your SlickGrid. You can modify the CSS rules to match your specific styling needs.