Combining multiple images into one CSS image sprite to create 4 clickable

Could someone please review this segment of the CSS to ensure its accuracy?

CSS

#nav-list {
    list-style-type: none;
    background-repeat: no-repeat;
    background-image:url("../_img/Footersprite.png") 
}

#nav-list li, #nav-footer a {
    height: 40px;
    display: block;
}

#nav-list li {
    float: left;
    list-style: none;
    display: inline;
    text-indent: -9999em;
}

#nav-list-why-repair-01 { width: 98px; }
#nav-list-savings-02 { width: 131px; }
#nav-list-enviromental-03 { width: 123px; }
#nav-advantage-04 { width: 138px; }

#nav-list-why-repair-01 a:hover { background:url(./_img/Footersprite.png) 0px -40px no-repeat; }
#nav-list-savings-02 a:hover { background:url(./_img/Footersprite.png) -98px -40px no-repeat; }
#nav-list-enviromental-03 a:hover { background:url(./_img/Footersprite.png) -229px -40px no-repeat; }
#nav-list-advantage-04 a:hover { background:url(./_img/Footersprite.png) -352px -40px no-repeat; }

HTML

<ul id="nav-footer"
<a class="whyroofrepair" href="/why-roof-repair.html">Why Roof Repair?</a>
<a class="Savings" href="/savings.html">Savings</a>
<a class="EnvironmentalBenefits" href="/environmental-benefits.html">Environmental Benefits</a>
<a class="RoofRxAdvantage" href="/roof-rx-advantage.html">Roof Rx Advantage</a>
</ul>

I require assistance with the HTML. Can anyone offer advice on how to rephrase this correctly without altering the provided CSS assuming it is correct?

Answer №1

If you're uncertain about the appearance of the links, you can align the HTML with the CSS provided by structuring it like this:

<ul id="nav-list">
    <li><a class="whyroofrepair" href="/why-roof-repair.html">Why Roof Repair?</a></li>
    <li><a class="Savings" href="/savings.html">Savings</a></li>
    <li><a class="EnvironmentalBenefits" href="/environmental-benefits.html">Environmental Benefits</a></li>
    <li><a class="RoofRxAdvantage" href="/roof-rx-advantage.html">Roof Rx Advantage</a></li>
</ul>

It may be necessary to eliminate the text-indent: -9999em; from the CSS if visibility of the link text is desired.

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

Collaboration of Bootstrap components

I am facing an issue with two divs that are supposed to be displayed side by side in a normal browser. However, when the browser window is resized, the first div loses its height and the second div overlaps into it. I attempted to set the body's min h ...

Error encountered in PHP due to a spacing issue in the GET

<?php $current_subject = $_GET['subject_id']; $current_content = $_GET['note_id']; echo "<form method=\"post\" action=mainpage.php?subject_id=".$current_subject."&note_id=".$current_content.">"; ?> <in ...

Updating Button Text with PHP on WooCommerce

Hi there, I'm trying to find a way to translate a button in my WooCommerce store without using LocoTranslate or any other tools. Is there a PHP function that can help me change the button text without needing an ID? If you want to take a look at the ...

Prevent border duplication in CSS and retain border visibility

Check out this fiddle where I have three divs with a border-width of 2px. Originally, the issue was that each div's border gets duplicated in between, resulting in a total border-width of 4px. To solve this, I applied a margin-top of -2px to each div, ...

Unlock the potential of HTML5 Datalist: A comprehensive guide on integrating it with

The latest version of HTML, HTML5, has introduced a new tag called datalist. This tag, when connected to <input list="datalistID">, allows for autocomplete functionality on web forms. Now the question arises - what is the most efficient approach to ...

The content within the iframe is not properly sized

I'm facing a challenge with an iframe that has a fixed height of 1000px which I am unable to adjust. I would like the content to fit within the iframe. As a CSS novice, I need some guidance on how to achieve this. Thank you! <iframe style="height: ...

Missing 'id' property in ngFor loop for object type

I'm currently learning Angular and I've been following a code tutorial. However, despite matching the instructor's code, it doesn't seem to be working for me. When I try to compile the following code, I receive an error message stating ...

Zooming on a webpage is causing problems

One issue I'm facing is with the elements on my page acting strange when I zoom in and out. Everything seems to be working fine except for a container div that should overlay a color over the image background. When I zoom in or switch to mobile view, ...

Trouble with submitting data to SQL database using the input form

I am currently working on a website where I need to transfer data from an HTML form to a SQL database. Here is the code for post.html: <form action="send_post.php" method="post"> <h3>ID:</h3> <input type="text" name="id"> <h3&g ...

The behavior of Elementor lightbox buttons upon being clicked

When using Android, I've noticed that the lightbox briefly displays a semitransparent cyan bar on the left and right buttons when they are pressed. Is there a way to control or prevent this behavior? Any suggestions would be appreciated! Thanks in adv ...

Struggling to receive a response from request.POST.get within the index function of views.py

I am struggling to develop a web application that shows the IP Address of a hostname entered by the user in a text field. Unfortunately, I keep encountering an error where I can't seem to get a response from the URL. As a beginner in this field, I wou ...

Inserting blocks of text into a MySQL database

I'm hoping to insert text segments into a MySQL database. Below is an excerpt of my HTML code: <div class="margins3"> <h1>Meal Plan...</h1> <div id='results-container'> <div class='LeanMuscle ...

A table featuring an HTML select element that allows users to choose from preset options or manually enter

My goal is to incorporate a select box where users can either choose from a set list of options or input their own custom value. The select element is nested within a table. Unfortunately, using datalist is not a viable solution for me in this case. I have ...

Surprising CSS overflow error

Recently, I've encountered a CSS overflow issue while working on a responsive webpage. The problem seems to be stemming from the navigation menu. The declaration of "overflow-x: hidden" is specifically causing the trouble... Initially, I suspected i ...

What is causing Ajax to fail in connecting to the server?

When trying to submit a simple ajax form and send a response to my server, I keep getting the following error message : Forbidden (CSRF token missing or incorrect.): /designer/addOne/ [31/Jul/2017 12:49:12] "POST /designer/addOne/ HTTP/1.1" 403 2502 Alt ...

Storing user-provided image files in Laravel: A comprehensive guide

I am facing an issue with a file insert box in my HTML file. The code looks like this: <input id="image" type="file" name="image" value="{{ old('image') }}" accept="image/gif, image/jpeg, image/png& ...

Conceal specific image(s) on mobile devices

Currently, I am facing an issue on my website where I need to hide the last two out of six user photos when viewed on mobile or smaller screens. I believe using an @media code is the solution, but I'm unsure about the specific code needed to achieve t ...

Different methods to disable scrolling when the mobile menu pops up

I have implemented a mobile menu option that appears when you click on the triple line logo, but unfortunately, users can still scroll while the menu is open. I've tried using position:fixed; but haven't been successful in preventing scrolling be ...

Why is this element occupying an excessive amount of space horizontally?

I've been diligently working on a unique custom WordPress theme as part of a school project. Our task is to redesign the homepage of an association, in my case, a theater group. One of the challenges I encountered was customizing the WordPress menu t ...

I am interested in incorporating various forms within this code

I followed an online tutorial to create this code, and I've made some edits myself, mainly related to the buttons that display information. However, I'm still learning and struggling with adding different forms to each section. I would really app ...