nobody
nobody

Reputation: 11090

Site logo in header ASP.NET Core MVC

I have the following image tag that I am trying to add to my site.

<a href="@Url.Action("Index", "core")" class="navbar-brand">
    <img src="~/images/core.png" title="core" alt="additional title" />
</a> 

I've tried to add this tag in both head as well as body tags of my _Layout.cshtml page and it ends up just below the header.Where should I add the tag so that it appears at the top left corner of the site?

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>@ViewData["Title"] - core</title>

<environment names="Development">
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment names="Staging,Production">
    <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
          asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
          asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
    <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
@Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
</head>
<body>

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a asp-area="" asp-controller="core" asp-action="Index" class="navbar-brand">core</a>
        </div>
        <div class="navbar-collapse collapse">  

        </div>
    </div>
</div>
<div class="container body-content">
    @RenderBody()
    <hr />
    <footer>
        <p>&copy; 2017 - core Inc. - core</p>
    </footer>
</div>

<environment names="Development">
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
            asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
            asp-fallback-test="window.jQuery">
    </script>
    <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/bootstrap.min.js"
            asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
            asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
    </script>
    <script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>

@RenderSection("scripts", required: false)
</body>
</html>

In the body but this would place the logo below the head.

<body>
 <a href="@Url.Action("Index", "core")" class="navbar-brand">
    <img src="~/images/core.png" title="core" alt="additional title" />
</a>     
<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      .
      .
      .

enter image description here

Upvotes: 2

Views: 6788

Answers (2)

nobody
nobody

Reputation: 11090

I figured it out myself.It needs to go inside the <div class="navbar navbar-inverse navbar-fixed-top">

<div class="navbar navbar-inverse navbar-fixed-top">
    <a href="@Url.Action("Index", "core")" class="navbar-brand">
        <img src="~/images/core.png" title="core" alt="" />
    </a> 
    <div class="container">         
        <div class="navbar-header">

enter image description here

Upvotes: 2

Chen Zissu
Chen Zissu

Reputation: 73

try: position:relative top: (add here the amount of pixels)

another option is to use position: absolute and change the logo's place, you may also send me a private msg and I'll try to help you more with more code/direct link to your site

Upvotes: 0

Related Questions