Angular 6 - How to apply external css stylesheet (leaflet) at component level?
Ok, here's what worked (thanks @Palsri, I read once more the blog post and the Angular styling guidelines and tried the following, which worked):
In a separate css file, import the leaflet css:
// map.component.css
@import url("../assets/lib/leaflet/leaflet.css");
.mapstyle {
width: 100%;
height:100%;
};
Then in the component, reference this css instead of the leaflet css as follows:
@Component({
templateUrl: "./map.component.html",
selector: "app-map",
styleUrls: ["./map.component.css"],
encapsulation: ViewEncapsulation.None
})
Here's the code in the html template:
<div id="map" class="mapstyle"></div>
One more thing: for the height % to work, you need to define the parents size, which I currently did in the index.html as follows:
<style>
html, body {
min-height: 100% !important;
height: 100%;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
</style>
Doing this
@import url("path")
ex:
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css")
or doig also
@import "bootstrap/dist/css/bootstrap.min.css"