Link with an embedded background image

When I click on the 'law firms' image in my project, instead of displaying a short HTML page with text as intended, it shows a '>' character. I have three circular images on my jsFiddle, and when hovered over, a background shadow image is rendered. How can I make the image itself act as the link, while also keeping the background image centered over the law firms image when hovered over?

Below is the CSS code:

.center {text-align: center;}

#sfimages {padding:15px;}

#sfimages:hover {
background-image: url(http://ubuntuone.com/1SRrDB8i8cBtpm3Smxaz5r);
background-repeat: no-repeat;
background-position:center;     
}

And here's the HTML code:

<body>
<table style="width: 100%">
    <tr>
            <td class="center">
                <div id="sfimages"> 
                <a href="http://ubuntuone.com/3JHwAhFuNUCVfq1QOOjBGG">                              >
                <object type="image/svg+xml"
                    data="http://ubuntuone.com/5b5ZUS86nHAffWiOirDwFr">
                    <img src="http://ubuntuone.com/12qOaTGCZYzQtqFJpaGbPV" alt="" />
                </object>
                </a>
                </div>
            </td>
            <td class="center">
                <div id="sfimages">
                <object type="image/svg+xml"
                    data="http://ubuntuone.com/6tkHm9c2r1eH9PMB9Nr3Ux">
                    <img src="http://ubuntuone.com/54AaqhQUU8npACF2vXzKFp" alt="" />
                </object>
                </div>
            </td>
            <td class="center">
                <div id="sfimages">
                <object type="image/svg+xml"
                    data="http://ubuntuone.com/7Ur09JXlGVvF2GhXFbLXlx">
                    <img src="http://ubuntuone.com/4CXw05d1dsSf9VhAIPNZf6" alt="" />
                </object>
                </div>
            </td>
    </tr>
</table>

Answer №1

After a busy day, I finally have some time to address your question. It seems like you're working with code from Inkscape, which can be quite messy, especially in the object area. But don't worry, if you want to add links, just make a few adjustments as outlined below:

The CSS:

.center {
    text-align: center;
}

#sfimages {
padding:15px;
position:relative;
width:380px;
height:273px;
}

#sfimages:hover {
    background-image: url(example-url);
    background-repeat: no-repeat;
    background-position:center;     
}

#ext-site {
display:block;
width:380px;
height:273px;
position:absolute;
z-index:9999;
}

The HTML:

<table style="width: 100%">
    <tr>
            <td class="center">
                <div id="sfimages"> 
                <a id="ext-site" href="example-link"></a>                              
                <object type="image/svg+xml"
                    data="example-data">
                    <img src="example-image" alt="" />
                </object>

                </div>
            </td>
            <td class="center">
                <div id="sfimages">
                <object type="image/svg+xml"
                    data="example-data">
                    <img src="example-image" alt="" />
                </object>
                </div>
            </td>
            <td class="center">
                <div id="sfimages">
                <object type="image/svg+xml"
                    data="example-data">
                    <img src="example-image" alt="" />
                </object>
                </div>
            </td>
    </tr>
</table>

This trick involves using an absolute positioned anchor link inside a relative display block element. The anchor acts as an invisible button covering the entire section when it stretches to the size of its parent.

Feel free to check out my Fiddle for more details.

Answer №2

There seems to be an extra character present: Please review the following code (a link to the full code is provided within a comment):

<table style="width: 100%">
    <tr>
        <td class="center">
            <div id="sfimages"> 
            <a href="http://ubuntuone.com/3JHwAhFuNUCVfq1QOOjBGG">                              
            <object type="image/svg+xml"
                data="http://ubuntuone.com/5b5ZUS86nHAffWiOirDwFr">
                <img src="http://ubuntuone.com/12qOaTGCZYzQtqFJpaGbPV" alt="" />
            </object>
            </a>
            </div>
        </td>
        <td class="center">
            <div id="sfimages">
            <object type="image/svg+xml"
                data="http://ubuntuone.com/6tkHm9c2r1eH9PMB9Nr3Ux">
                <img src="http://ubuntuone.com/54AaqhQUU8npACF2vXzKFp" alt="" />
            </object>
            </div>
        </td>
        <td class="center">
            <div id="sfimages">
            <object type="image/svg+xml"
                data="http://ubuntuone.com/7Ur09JXlGVvF2GhXFbLXlx">
                <img src="http://ubuntuone.com/4CXw05d1dsSf9VhAIPNZf6" alt="" />
            </object>
            </div>
        </td>
    </tr>
</table>

Answer №3

Step 6:

<a href="http://ubuntuone.com/3JHwAhFuNUCVfq1QOOjBGG">                              

Make sure to remove the unnecessary closing bracket.

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

Why does the "margin" CSS style fail to function properly in FlowPanel within GWT?

I'm currently working with Gwt and have encountered a problem with styling buttons. Let's take a look at the following code snippet: .marginRight{ margin-right: 10px; } FlowPanel myFP=new FlowPanel(); Button myButton=new Button("Button"); Butt ...

CSS - Is there a way to alter the arrangement of DIVs depending on the size of the screen?

My inquiry pertains to a CSS layout. I currently have 3 divs positioned in a horizontal line next to each other, as depicted below... div1 div2 div3 I am aiming for the divs to reorganize themselves as the screen size decreases. In one scenario, they sho ...

What is the point of the horizontal scroll bar in WP Thesis?

There seems to be a horizontal scroll bar appearing at the bottom of my site, even though there is no content extending beyond the visible area. Can anyone provide guidance on how to fix this issue? My website is built on Wordpress 3.0 and utilizes the Th ...

website: What is the best way to embed an input field within an image?

Is it possible to incorporate an image into my website design similarly to Google's simple approach? <img src... done... > Additionally, I would like to add an input box over the text area of the picture. How can I achieve this? ...

Include various categories into the div containers of the listed items within the query outcomes

Is there a way to customize div styles based on query results? I want to differentiate the styles of divs in the result list based on their content. For example: I'd like bird names in the result list to have different div styles compared to other a ...

Bootstrap - Keeping track of the collapse state of <div> elements after page refresh

Looking for some guidance as a javascript/jquery beginner - I am utilizing Bootstrap along with data-toggle and collapse classes to display or hide divs. I have been searching online trying to find a solution that will maintain the state of all divs, wheth ...

Tips for Displaying JSON Data on an HTML Page

How can I display JSON data in an HTML web page and group names from the JSON Data only? Here is the URL for the data: http://www.celeritas-solutions.com/pah_brd_v1/productivo/getGroups.php?organizationCode=att&userId1 I have searched online and fo ...

Instructions on separating an array into two table rows "<tr>" with a single foreach loop on the template side

Given the constraints of my working environment, I must divide this array into two separate table rows - one containing half of the data and the other with the remaining half. The array is already sorted in the order that I require: Array ( [product] ...

Change element position to relative while scrolling

I created a wrapper with an animation similar to the one on Apple's Airpods Pro page. It features a video that plays gradually as I scroll, with the text smoothly scrolling over it within a specific area (text-display). So far, this part is working w ...

Guide on integrating jQuery for AJAX responses to gracefully transition into view within an MVC3 View

Is there a way to create a smooth fade in effect for a <p> element on my website? Currently, I am using Ajax to retrieve the server time and display it. However, the elements appear abruptly and I would like to make the transition more gradual by ad ...

The Bootstrap Dynamic Navbar is not adjusting for mobile devices because of the addition of a logo

Struggling to incorporate a logo into the navbar of my website. It looks good on larger screens, but causes the navbar to break on smaller screens. View without the logo: Click Here View with the logo and resizing issues: Click Here I think I can make th ...

Tips on finding an error message within the website's developer options when the inspector fails to locate it

I'm dealing with a website at On this site, there's a 'get latest blog posts' field that I want to automate the error message for. When I input an invalid email address like test123.com, I receive an error response but can't find ...

JS unable to insert new row in table

I checked the input value before submitting it in the form and confirmed that it is correct, returning as a string.enter image description here const saveList = () => { const inputListNameText = inputListName.value; fetch('/api/lists' ...

Revamp Django form submission route according to dropdown selection

I'm currently working on an internal search engine that features multiple options in a dropdown. While it works initially, I want to modify the form to retrieve URLs based on the dropdown selection, like so: example.com/search/**Option_Value_Here**/? ...

Steps to trigger an alert when the entered quantity exceeds the current stock levels

After developing an IMS System, I encountered a problem where my stock is going into negative figures. To resolve this issue, my primary goal is to trigger an alert whenever the quantity entered by a user exceeds the available stock. For example, if a us ...

Attempting to connect JQuery to a different page through a data attribute connection

I am currently working on a slider that connects slides from an external page through data attributes. Here is the setup: Main Page <div id="sitewrapper"> <section class="sliderwrapper"> <div id="slider" data-source="slides-pa ...

What could be causing the issue: Unable to locate or read the file: ./styles-variables?

I'm currently following a tutorial on how to create responsive layouts with Bootstrap 4 and Angular 6. You can find the tutorial here. I've reached a point where I need to import styles-variables.scss in my styles file, but I keep encountering t ...

The initial element within the div style is malfunctioning

Could someone assist me in understanding why the first-of-type CSS is not working correctly? .item:first-of-type .delete{ display: none ; } .delete { text-decoration: none; color: red; padding-top: 40px;} .add_form_field { white-space: nowrap; } < ...

Making a Django template recognize the load tag when inheriting from a base template involves ensuring proper syntax and file

My current setup involves a file called base.html. {% load static from staticfiles %} <html> <title>COOL| {% block title %} Sometitle {% endblock %}</title> <body> <!--- BEGIN INSERT CONTENT FOR OTHER PAGE HERE--> ...

Unable to align span vertically using font-style "Luckiest Guy" in CSS

I have encountered an issue with vertically centering a span using the font-style "Luckiest Guy". https://i.sstatic.net/Lz8o3.png I attempted to use display: flex;align-items: center; on the span, but it did not work. App.vue <template> <div ...