The CSS link will only appear when hovering over the image

I'm having trouble getting the f1 link to appear on an image only when hovering over the image. I tried some code but it's not working, the link is not appearing. Can someone help me understand what the problem is and provide a solution?

<div class="caine1">
      <img src="1.png" width="400" height="250"></img>
      <a href="#" id="f1">Female</a>
       </div>

   

    #f1 {
    position:absolute;
    display: none;
    z-index: 200;
}


.caine1 img:hover #f1 {
    display: inline-block;
}

Answer №1

Make sure to include the + in your code.

#f1 {
  position: absolute;
  display: none;
  z-index: 200;
}

/* Don't forget the + in this section */
.caine1 img:hover + #f1 {
  display: inline-block;
}
<div class="caine1">
  <img src="1.png" width="400" height="250" /> <!--Also, images are self-closing tags-->
  <a href="#" id="f1">Female</a>
</div>

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

Error: Morris.js is unable to access the property 'x' because it is undefined

Seeking assistance in utilizing Morris.js to create an area chart using data from a JSON file. The JSON data is as follows: [{"period": 0, "time": 121.0}, {"period": 1, "time": 102.0}, {"period": 2, "time": 104.0}, {"period": 3, "time": 91.0}, {"period": ...

Ensure that the div spans the entire width of the page, prioritize maintaining the aspect ratio, but allow for variable

I have a dilemma with a div containing multiple elements. My goal is to make the div 100% in width, while also attempting to preserve the aspect ratio if feasible. Should the enclosed elements exceed the div's boundaries, then the height will adjust a ...

Tips for making a fluid DIV expand to fit the entire width of the page

My layout features fixed-width sidebars on the left and right, with a fluid main content area that fills the space in between using float:left. Here's an example: #left-sidebar {width: 200px;} #right-sidebar {width: 300px;} #main-content {margin-left ...

Incorporating a React element into a JavaScript object's property: A comprehensive guide

Below is a React Element named Info that has been attached to a Javascript object named myObj: let Info = ( <Info type="green" /> ); let myObj = { ReactComp: Info }; Now, the goal is to render the Info component using the above myObj objec ...

Appending a forward slash at the end of a URL seamlessly directs the user to a serendipitous webpage experience, while

I'm currently developing a project on this website: Interestingly, when you append a forward slash to the end of the URL, all the images mysteriously disappear. Consequently, I am unable to include Google AdWords tracking code at the end of any URLs: ...

Expanding the padding of the selected item to create more breathing room

Upon examining the following: https://jsfiddle.net/h8kmove5/27/ Let's say you select 9 at the bottom. The display shows 8 9 10. My intention is to create some additional space on either side of 9, or any other active item for that matter. This way, ...

Error JSON material for MeshFaceMaterial encountered

Successfully loaded my model using the following code: loader.load( "js/charWalk01.js", function( geometry, materials ) { mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial() ); scene.add( mesh ); } ...

Customize the Hidden Footer in Wordpress

I have a question about the footer code in my theme. I want to remove the "Powered by WordPress" text, but I can't seem to find the solution here. Can someone please help me with this? <?php do_action( 'maxwell_before_footer' ); ?> & ...

What is the best way to modify the class of my <li> element with JavaScript?

My asp.net project utilizes a master page that includes a list within it. <ul id="navigation"> <li id="li1" runat="server" class="selected"><a href="Events.aspx">Events</a></li> <li id="li2" runat="server ...

Updating the parent component does not automatically update the props in the child component

Within my parent component, I have established the state that is then passed down as props to the child component. Additionally, I am passing the "onUpdateQuestion" function in the child component's props. This function triggers a re-render each time ...

Tips for customizing the scrollbar design in iOS Safari

Task at hand requires me to customize the scrollbar style on my HTML page. Below is the CSS code I am using: .txt_Content::-webkit-scrollbar { width:5px; border-radius:4px; } .txt_Content::-webkit-scrollbar-button { display: none; } .txt_Co ...

Having trouble rendering a dynamic table with JavaScript utilizing a JSON object

I am struggling to retrieve data in JSON format and display it in a table. Despite trying various methods, I have been unable to make it work. Below is the code for this function. Can someone please assist me in identifying what is wrong with it? As of now ...

Establishing a restricted channel exclusive to a specific role for joining

I want to create a special channel where only members from the partyInvitees collection (Collection<Snowflake, GuildMember>) can join. const permission = Discord.Permissions.FLAGS; message.guild.createRole({ name: message.author.username + "&apos ...

Having trouble capturing user_id in my dashboard component - Laravel and Vue.js combination

I am facing an issue with extracting user_id from my dashboard Vue component TableEditLinks.vue. When I try to change user_id in the submitForm() method from "1" to "document.querySelector("meta[name='user_id']").content('content')", it ...

In JavaScript or jQuery, what is the most optimal method to swap out all instances of a specific string within the body content without altering the rest of the body text?

Is there a way to replace specific occurrences of a string within a web page's body without disrupting other elements such as event listeners? If so, what is the best method to achieve this? For example: Consider the following code snippet: <body ...

Unable to close Bootstrap 5 modal

All of my modal forms are functioning properly, except for one that I migrated from Bootstrap 4 to Bootstrap 5. This particular modal refuses to close. Neither the Close button (the X at the top of the popup) nor the Cancel button will close the modal. I ...

Transforming the timezone of a date from the Backend to the timezone selected by the user in the User

I have an API that provides dates in the format: 12/23/2023 at 03:31 a.m. CST My goal is to convert this to a date with the user-selected timezone in the following format: 12/23/2023 at 7:31 p.m. The timezone part is not required for display in the UI. c ...

Utilizing Selenium to interact with textfields and simulate triggering events, replicating human-like behavior

Currently, I am facing a challenge in testing a webpage using Selenium which has been developed using AngularJS. This particular webpage contains text fields that users need to fill out. As the user starts typing in these text fields, AngularJS captures ea ...

Finding an element with Protractor by executing JS script

My objective is to retrieve a drop-down list of elements. Despite trying Protractor's methods, I struggled to easily locate isolate-span elements. Due to this, I am now turning to JavaScript code: var my_js_element = browser.executeScript(jQuery("td. ...

What is the best way to modify React state?

Can someone help me troubleshoot an issue with toggling React state after a button click? I want to be able to change "Work From Office" to "Work From Home" and vice versa, but it's only working once. Is there a way to achieve this using an if stateme ...