When it comes to CSS, external style sheets are the implementation type that you would want to be aiming for when developing with HTML dashboards. An external style sheet will be made available in one central location and reusable across all your code within your environment, and if hosted on a web server, would be available across multiple environments and locations.
In our previous example, we set up some internal style definitions to set up how our menu will look and operate, and it seems like the perfect opportunity to move these style definitions into an external CSS file. Log back into your development environment and we will get started with setting up an external style sheet to be used in our dashboard code:
cd $SPLUNK_HOME/etc/apps/stock_market/appserver/static/
stock_market_rules.css
.1 body { 2 margin: 0; 3 } 4 5 ul.side { 6 list-style-type: none; 7 margin: 0; 8 padding: 0; 9 width: 25%; 10 position: fixed; 11 overflow: auto; 12 background-color: #e6f2ff; 13 }
14 li.side a { 15 display: block; 16 color: #000; 17 padding: 8px 0 8px 16px; 18 text-decoration: none; 19 color: red; 20 } 21 22 li.side a.active { 23 background-color: #4CAF50; 24 color: white; 25 } 26 27 li.side a:hover:not(.active) { 28 background-color: #555; 29 color: white; 30 }
raw_stock_market_historical_overview_html.html
file again. We now need to add a reference to the new external CSS file that we have just created. We will add this to the header of the HTML. You may remember that at the start of this chapter we added our first external CSS file that set up the United theme for our dashboard. We will add our new external CSS file just below that by adding in the following line of code:12 <link rel="stylesheet" type="text/css" href=" {{SPLUNKWEB_URL_PREFIX}}/static/app/stock_market/ stock_market_rules.css" />
3.129.210.17