Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How can i set a background image specifically in a component?

Hello, 
I'm using Angular 4 for a project at school, I am able to set a background image in the general styles.css for index.html
But I only need to display that image in a specific component view and I can't.
This is what I do:
image.png.f4bb15192859ea2daf4bd3f06776a964.pngimage.png.075e6b2157b3962631e7df2a61367dd2.png
fondo.jpg is on root of panel component folder
Also tried using div as the element for the css file, body too, but It's supposed that body is actually on the main index.html
What do you think is the solution?
Thanks for your help! :)
 

Link to comment
Share on other sites

Link to post
Share on other sites

Well, I use routes, those routes are fed by components, I have a component per form for example, there is a component for my header, another for my footer, etc.
Each component has its own html, ts and css file
I want an image to be displayed as a backgorund image when I go to that component.
My English is not good, I may not be clear. 

Link to comment
Share on other sites

Link to post
Share on other sites

You could put it into the CSS file of the component and then reference the specific component with CSS:

panel {
  background-image: url(YOUR_IMAGE_HERE);
}

 

This way the background image will render inside your component.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×