Incorporate an image by utilizing the Href Id while applying CSS styling

I am currently working on a Wordpress website and I am struggling to add an image before a hyperlink.

For example, I have the following hyperlinks:

https://i.sstatic.net/NeSDa.png

https://i.sstatic.net/s8kjy.png

I have attempted using CSS to achieve this by writing:

 background: url("outline.png") no-repeat 6px center;
  width: 100px;
  height: 100px;
  display: block;

However, the image is not displaying correctly. Some parts of the image are going into the background. I also tried using z-index: 99999 to bring it to the front but with no success.

Answer №1

One method to consider is utilizing the :before element. Below is a sample code snippet customized for your website:

a#launch-tab-4:before {
    content: " ";
    width: 100px;
    height: 100px;
    display: block;
    background: #00aa00;
}
a#development-tab-4:before {
    content: " ";
    width: 126px;
    height: 100px;
    display: block;
    background: #eeaaff;
}
a#planning-tab-4:before {
    content: " ";
    width: 100px;
    height: 100px;
    display: block;
    background: #00eeff;
}
a#brainstorming-tab-4:before {
    content: " ";
    width: 100px;
    height: 100px;
    display: block;
    background: #000;
}

Your result should resemble this https://i.sstatic.net/Cshvv.png

Simply replace the colors with your own images while adjusting the dimensions as needed.

Answer №2

Consider using the CSS properties background-size:cover or background-size:contain

Hopefully this suggestion proves useful

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

Execute a PHP function using jQuery on the current page and display the output in a new

As a novice in jquery and ajax, I have thoroughly researched various threads and tutorials on this topic. Despite my efforts, I am still facing an issue. <script type="text/javascript"> $(document).ready(function(){ ...

Building a family tree with JavaScript's Document Object Model

My goal is to use jQuery to construct the following DOM setup: <li> <label> user <input type=radio> </label> </li> Below is the jQuery code I am trying to use. $('<input>') .attr({type:'radio&ap ...

Confirm that only the days of the present month are eligible for selection

I have been given the responsibility of validating a date field that is populated when an invoice is created. The date field consists of a text box and three button objects allowing users to select a date from a calendar, input today's date, or remove ...

Move the last specified elements to the beginning of the array

I have an array let colorsArr = ["red", "green", "purple", "pink", "black"]; Is there a way to retrieve a specific number of elements from the END and move them to the BEGINNING of the array? Desired result: example 1: //move last 3 elements let expec ...

I've been attempting to adjust the currentTime of an HTML5 video element within a React JS environment, but for some reason it keeps reverting

Need help updating the currentTime of an HTML5 video element with a slider in React JS. My issue is that whenever I adjust the slider, the value resets to 0. The problem seems to be related to the handleChange function which updates the videoRef.current.cu ...

Issue with the execution of Javascript code. Edit required

After creating a registration form that allows users to input their information for registration, I encountered an issue where if certain fields were left empty or if the user name was unavailable or the email address was already registered, a warning mess ...

Update button text in real-time using JavaScript

I am currently working on a dropdown list that contains 5 elements displayed inside a button when pressed. I want the button to show a default text "Filter by:" before displaying the selected tab value. Additionally, I need the caret symbol to be visible. ...

Is there a way to refresh the index data with ajax jQuery?

I'm working with an array of data retrieved via the Ajax GET method. Currently, I am displaying this data using its index number such as data[0]. To access the next set of data, I click on a button that should update the index from "here 0" to fetch d ...

Is there a way to launch an android application directly from my website using a pop-up box?

I attempted to utilize the following code: intent://my_host#Intent;scheme=my_scheme;action=my_action; and it appears to be functioning properly. However, I am in need of a dialog box similar to this image. Can anyone assist me with achieving this? Thank ...

PHP query will execute even in the absence of clicking the button

I'm encountering an unusual issue. I've defined a query to insert two names into the database, and I've used Javascript(Jquery) to ensure it only runs when the create button is clicked. However, the script seems to be executing every time I ...

Is it possible to incorporate jQuery Ajax into a Laravel + vue application?

As I embark on developing a Software as a Service web app, I find myself in a dilemma regarding the best approach to take. With over 3 years of experience working with PHP (core) and jQuery Ajax, I am now transitioning to Laravel and Vue.js. I am wonderi ...

How can I use jQuery.cycle to change the background image of a

Seeking advice on jQuery! I am struggling to figure out how to use the Cycle plugin to change the background image of a div instead of cycling through slides. I have other content in the div that I want to remain unchanged. Does anyone know of another pl ...

jQuery .click() function doesn't seem to be triggering as anticipated

My goal is to create an interactive functionality where: When a user clicks on the h4 element inside a .question divThe .question div expands to a height of 90px, and its child paragraph slides into view with a margin-top of 0If the user clicks the h4 el ...

Expanding Overlay Width in Vuejs and CSS for Small Devices under 500px

How can I adjust the width of the overlay nav specifically for small devices in Vue or CSS? My current width is set to 25% for devices with a width of 1000px or more, but I need a different width of 35% or more for smaller devices to improve text visibilit ...

Tips for creating a floating navbar with separated lists using Bootstrap 4

Struggling to position my navbar to the right and separate the list within the navbar. Despite multiple attempts, I can't seem to get it right. Here is a snippet of the code I've been working on: here is what I'm trying to achieve $def with ...

Tips on incorporating HTML element tags within a JSON value

I have successfully bound JSON data to an HTML table using Ajax and JavaScript in my project. The table has four headers: S.no, name, year, and download link. The first three columns are syncing and working correctly without any errors. However, for the la ...

Error in the jqplot Line Graph

I'm having trouble displaying a chart on my webpage. The console shows that the chart is being drawn, but it's not showing up on the page. I've checked that the container is added correctly, but I can't figure out where the issue lies. ...

Distinguish individual elements within JSON from each other

Despite my limitations in altering the server-side code that generates this JSON: [ { test_id: "1", test_name: "Diagnostic Test 1" }, { test_id: "2", test_name: "Test 1" }, { test_id: "3", test_name: "Test 2" } ] I am ...

conceal the present element using jQuery while dealing with numerous identical elements

When clicking on an element, I am attempting to hide that specific element. However, all elements share the same id and I need each one to hide individually upon click. Typically, I would use PHP in a foreach loop to add an incremental value to each ID. U ...

Completes a form on a separate website which then populates information onto a different website

Creating a website that allows users to login and view various complaint forms from government websites or other sources. When a user clicks on a link to file a complaint, they will be redirected to the respective page. However, I am looking for a way to ...