Placing a logo to the left of a UL list

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>N4N</title>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script> 
<script>
/**
 * @author Alexander Farkas
 * v. 1.21
 */


(function($) {
    if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
        var oldCurCSS = jQuery.curCSS;
        jQuery.curCSS = function(elem, name, force){
            if(name === 'background-position'){
                name = 'backgroundPosition';
            }
            if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
                return oldCurCSS.apply(this, arguments);
            }
            var style = elem.style;
            if ( !force && style && style[ name ] ){
                return style[ name ];
            }
            return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
        };
    }

    var oldAnim = $.fn.animate;
    $.fn.animate = function(prop){
        if('background-position' in prop){
            prop.backgroundPosition = prop['background-position'];
            delete prop['background-position'];
        }
        if('backgroundPosition' in prop){
            prop.backgroundPosition = '('+ prop.backgroundPosition;
        }
        return oldAnim.apply(this, arguments);
    };

    function toArray(strg){
        strg = strg.replace(/left|top/g,'0px');
        strg = strg.replace(/right|bottom/g,'100%');
        strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
        var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
    }

    $.fx.step. backgroundPosition = function(fx) {
        if (!fx.bgPosReady) {
            var start = $.curCSS(fx.elem,'backgroundPosition');

            if(!start){//FF2 no inline-style fallback
                start = '0px 0px';
            }

            start = toArray(start);

            fx.start = [start[0],start[2]];

            var end = toArray(fx.options.curAnim.backgroundPosition);
            fx.end = [end[0],end[2]];

            fx.unit = [end[1],end[3]];
            fx.bgPosReady = true;
        }
        //return;
        var nowPosX = [];
        nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
        nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
        fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

    };
})(jQuery);
</script>
<script>
$(document).ready(function() {
    $("ul#nav li a").addClass("js");
    $("ul#nav li a").hover(
      function () {
        $(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200);
        $(this).animate({backgroundPosition:"(0 -5px)"}, 150);
      }, 
      function () {
        $(this).animate({backgroundPosition:"(0 -149px)"}, 200);

      }
    );

});
</script>
<style>
html, body, div {
    margin: 0; padding: 0; border: 0;
}

body {
    background: #f5f0e0 url(noise.png);
}

ul#nav {
    width: 900px; margin: 0 auto; text-align: center; overflow: hidden;
    background: url(bg.jpg) center no-repeat;
}
    ul#nav li {
        float: left; list-style: none; 
    }
        ul#nav li a {
            display: block; width: 97px; height: 77px; 
            padding: 72px 0 0 0; margin: 0 32px 0 32px;
            font: bold 16px Helvetica, Arial, Sans-Serif; text-transform: uppercase;
            color: #9c5959; text-shadow: 0 1px 3px #c4bda6; text-decoration: none;

            background: url(label.png) 0 -149px no-repeat; 
        }
            ul#nav li a:hover {
                background: url(label.png) 0 0 no-repeat;
                color: #eee9d9; text-shadow: 0 2px 3px #4c2222;
            }

            ul#nav li a.js:hover {
                background: url(label.png) 0 -149px no-repeat;
            }

#topHdr {
}
</style>
</head>

<body>
<div id=topHdr>
    <div>
    <img src="logo.png" alt="Logo" style="float:left;margin-right:20px;" />
    <ul id="nav">
        <li><a href="#" title="Home">Home</a></li>
        <li><a href="#" title="Events">Events</a></li>
        <li><a href="#" title="About">About</a></li>
        <li><a href="#" title="Extras">Extras</a></li>
        <li><a href="#" title="Share Links">Share It</a></li>

    </ul>
    </div>
</div>
</body>
</html> 

Screenshot after using the script above:

I am trying to add a logo on left of the home like this:

Where do I change the CSS to achieve that?

Answer №1

To easily update your unordered list, start by inserting a new list item at the beginning with the desired image. Here is an example:

<ul id="nav">
   <li><img src="some_image.png" /></li>
   <li><a href="#" title="Home">Home</a></li>
   ......
</ul>

Next, modify the styling to ensure the new list item blends well with the others. Here's how you can adjust it:

ul#nav li  {
    width: 97px; height: 77px; 
}

You have the flexibility to customize the image style further by restructuring the CSS code. However, for a quick solution, applying the same style to all list elements will suffice.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transforming Text On Hover Using CSS, as well as Customizing the Style

I've been struggling with this issue for quite some time now. Despite scouring the first page of Google search results for "css change text on hover," I have not been able to find a solution. Inside a div, I have text that is styled and positioned us ...

Optimize flexbox navbar layout by eliminating unnecessary spacing between items

Greetings! As a novice in the world of web development, I must admit that I am facing some difficulties with my homework assignment. Despite my several attempts, I am unable to remove the spacing in the navbar on my university website clone project. It sim ...

Guide to implementing a delay in JavaScript/jQuery code right after invoking an asynchronous function

Is there a way to execute an asynchronous function and then introduce a delay in the subsequent code execution to ensure that the asynchronous operation has completed? I want to avoid wrapping the following code in a function and delaying it, I simply ne ...

"Send the selected radio button options chosen by the user, with the values specified in a JSON format

My current task involves inserting radio button values into a MySql database using Angular. The form consists of radio buttons with predefined values stored in a json file. Below is an example of how the json file is structured: //data.json [{ "surve ...

The Art of Determining the Text's Baseline

My goal is to create a test that determines whether the text rendered inside an <input> has the same baseline as a label: To achieve this, I want to calculate the baseline of the rendered text in each element and compare their values. Is it possible ...

The Media Query Menu is not aligned in the center for smaller screens, functioning in both medium and extra-small sizes

@import url('https://fonts.googleapis.com/css?family=Dosis'); * { box-sizing: border-box; } /*Xtra Small */ body { font-family: 'Dosis', sans-serif; line-height: 1.618em; font-size: 18px; background: #383231; c ...

The jQuery error message "e.nodeName is undefined" indicates a timeout issue

<script type="text/javascript"> var delayFunction = (function() { var timer = 0; return function(callback, ms) { clearTimeout(timer); timer = setTimeout(callback, ms); }; })(); $(function() { $('#act ...

When hovering the mouse over, the text fails to appear

Is there something wrong with my overlay on this image? It darkens when I mouse over, but the text I want to display does not show up. Any ideas? http://jsfiddle.net/cryycw3n/ HTML <div class="square"> <div class="info"> <h2&g ...

Generate a hard copy of the data table row without needing to view it beforehand

Here are some records from a table: +--------+---------+-------+----------+--------+ | Name | Address | Phone + Email | Action | +--------+---------+-------+----------+--------+ | Andy | NYC | 555 | <a href="/cdn-cgi/l/email-protection" cl ...

Looking for advice on using media queries to resize my background image - any tips?

I'm struggling to resize my background image using media queries. Can anyone offer suggestions or solutions? I've tried applying the media query for my background image like I do with other elements, and it's not working properly. The issue ...

PHP variable missing "+" sign at the end after post operation

I have encountered a unique problem that I cannot seem to find anywhere else. My issue lies in adding grades ending with a plus sign, such as B+, C+ or D+. I am able to add grades like A-, B-, C- and D- without any problem, but when it comes to adding a g ...

Positioning buttons and elements on top of a BootstrapVue Carousel slide: a handy guide

Can different elements be positioned on the BootstrapVue Carousel slide without restrictions, such as in any corner or position? I have attempted to accomplish this by nesting additional elements within <b-carousel-slide></b-carousel-slide> ...

You cannot assign type 'Node | null' to type 'Node' when attempting to loop through HTML elements in TypeScript

In my code, I am taking a raw Markdown string stored in 'markdownString' and using the marked.js library to convert it to HTML for display on a web browser. My goal is to extract all plain text values from the page and store them in an array of s ...

Guide to changing the background color of a table cell using jQuery

I have created an ASP.net webpage with an ASP GridView to showcase a data table. My goal is to implement JavaScript that will change the color of cells containing the value '0' to red. I believe I can achieve this using $("td").each or document. ...

showing a message in a pop-up alert box

$(document).ready(function(){ $(document).on('click', '#btnSave', function () { var fname = $("#fname").val(); var lname = $("#lname").val(); var email = $("#email").val(); var mobile = $("#mobile").val(); if(fname == ""){ alert(&apos ...

Is it possible to load ASP.NET MVC3 EditorTemplates using Ajax without repeating jQuery?

Utilizing EditorTemplates for elements such as DateTime, Colors, and more has been a key aspect of my form design. These templates are often loaded dynamically through Ajax as partial views. Instead of cluttering each editor template with several jQuery i ...

Creating a dynamic and adaptive horizontal SVG line for your website

Understanding how SVGs function is still a bit unclear to me. I know that the viewBox property plays a role in scaling SVGs, and I have come across advice suggesting not to specify height and width attributes when creating responsive SVGs. While there are ...

Creating a schema for a JSON element in KendoUI: A simple guide

Looking for assistance on writing the schema for a JSON object with specific structure. { sev: [{ t: "t1", v: v1 }, { t: "t2", v: v2 }], sum: [{ te: "te1", ve: ve1 }, { te: "te2", ...

Blank page received upon submission of Laravel Select2 application

I'm experiencing an issue with submitting a form using select2. After submission, I receive a completely blank page. I'm not sure why the controller is not working properly. All I need is to send the store id. <form id='filter' act ...

I'm having trouble getting the data to parse correctly in ajax. Can anyone explain why it's not working?

I have implemented a system where an excel file is uploaded using AJAX, and information about the success or failure of the upload is sent from the upload page to the PHP page using json_encode. However, I am facing an issue with accessing this data indivi ...