Jump to content

Why is the logo not shown in the nav? (HTML/CSS)

Hip
Go to solution Solved by C2dan88,

Then you'll have to resize the image if you want it to fit inside the grey header area.

Not sure what you mean -> picture is located on the grey nav bar. You might have an issue with the size of the image itself, so it might seem like it is below.

Otherwise if you want to play with the position of pic you can add:

#logo
...
position: relative; 
top: 100px; 
left: 100px;
...

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 3/6/2020 at 1:11 AM, rikitikitavi said:

Not sure what you mean -> picture is located on the grey nav bar. You might have an issue with the size of the image itself, so it might seem like it is below.

Otherwise if you want to play with the position of pic you can add:


#logo
...
position: relative; 
top: 100px; 
left: 100px;
...

 

Somehow this does not work. 

So the picuture itself is way bigger than the size I want to make it. This is the current result:

 

 

1111111111111.PNG

 

You see on the top left I kinda have a shadow where the picture should be and nothing else.

 

@AbsoluteFool I've added it now but it still does not work ?

Link to comment
Share on other sites

Link to post
Share on other sites

30 minutes ago, Hip said:

You see on the top left I kinda have a shadow where the picture should be and nothing else.

It showing like that because your #logo div is really small. (2.5em x 2.5em). Increase the size of the div to same size as your background image, or rather than apply the logo as a background image. Set the logo as an <img> in your HTML and do not set with/height in your CSS. 

 

Tip: Use your browsers built in developer tools element inspector for checking dimensions of elements on your webpage.

 

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, C2dan88 said:

It showing like that because your #logo div is really small. (2.5em x 2.5em). Increase the size of the div to same size as your background image, or rather than apply the logo as a background image. Set the logo as an <img> in your HTML and do not set with/height in your CSS. 

 

Tip: Use your browsers built in developer tools element inspector for checking dimensions of elements on your webpage.

 

So you mean like this? 

 

  <div id="logo">
                    <img src="rocket.png">
                </div>

 

#logo
{
    width: 2.5em;
    height: 2.5em;
    margin: 1em;
    
    position: absolute;
   
}

This is kinda too large ?

1111111111111.PNG

Link to comment
Share on other sites

Link to post
Share on other sites

Then you'll have to resize the image if you want it to fit inside the grey header area.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, C2dan88 said:

Then you'll have to resize the image if you want it to fit inside the grey header area.

I have done it and it works! Thank you!

 

1111111111111.PNG

 

Here is the code:

 

#logo
{
    width: 2.5em;
    height: 2.5em;
    margin: 1em;
    
    position: absolute;
   
}

#logo img 
{
    width: 2.5em;
    height: 2.5em;
}

 

I see that I can even delete the logo with the <img> way and just have #logo img {...} 

 

 

Can you tell me how to solve this without the <img> and as backgorund-image instead, I'm curious ? Thanks in advance!

Solved

 

I have found a way to do this with background-image

 

  <div id="logo">
               
                </div>
#logo
{
    margin: 1em;
    width: 2.5em;
    height: 2.5em;
    background-size: 2.5em 2.5em;
    background-image: url("rocket.png");
}

 

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

×