Display of div content when hovering over table

I am currently developing a simple interactive calendar, and I need some guidance on how to make it more dynamic. Initially, I want only the months to display, but upon hovering over a month, I would like all the individual days to appear. Eventually, users should be able to click on each day to view its content.

If you'd like to take a look at what I have done so far, please visit: http://jsfiddle.net/r8orrebk/

Here is a snippet of the HTML structure:

<div id = "calendar">
<div class="month">
    January
    <table class="days">
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
            <td>4</td>
        </tr>
       ...
    </table>
</div>
...

<p>and here is a snippet from the CSS file:</p>

<pre><code>.days {
    display: none;
    border: 1px solid;
}
.month {
    width: 24%;
    height: 150px;
    float: left;
    border: 1px solid;
    margin: -1px 0 0 -1px;
}
.month:hover > .days {
    display: block;
}

I'm looking for suggestions on the best way to achieve this functionality. Since I'm new to HTML and CSS, I'm not sure if using a table is the right approach. Should I consider incorporating javascript/jquery instead of solely relying on CSS hover effects?

Additionally, I'm wondering if there's a more efficient way to populate the days within each month rather than manually creating a div or td for each day as I've done thus far.

Any advice or recommendations would be greatly appreciated. Thank you.

Answer №1

If the .days element is activated and has a display:block property, it will automatically become 100% wide, as this is the default behavior for block elements.

To correct this issue, you can change the display property to table instead of block:

.month:hover > .days {
    display: table;
}

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

I'm curious if there is a configuration option in nodejs that allows for monitoring every ajax call, similar to zend's predispatcher feature

In my current task, I am required to verify every API call for authentication purposes (checking if the API call includes an API key). If the API call contains the API key, then proceed with calling the API and returning its response; otherwise, return an ...

Conflict of JQuery ajax requests with the Play! framework

Whenever I trigger an action on my page, two ajax calls (A, B) are made to different methods on my server. Most of the time, each request receives its corresponding response. However, occasionally both requests receive the same response! (either A,A or B,B ...

Customize the select option in HTML to hide the default arrow and provide additional spacing for the options

I am dealing with a select option markup that looks like this <div class="styleselect"> <select onchange="setLocation(this.value)" class="selections"> <option selected="selected" value="position">Position</option> <opt ...

Show a message on form submission rather than redirecting

I'm working on a simple sign-up form and I want to show a success message directly on the page instead of redirecting to another page after submission. Is it better to display the message as a pop-up, an alert, or just on the page itself? <form a ...

Is it feasible to customize the icon for the expand/collapse button in the header of jqGrid?

To begin, let me provide some context. In my view, I have 2 or more grids (jqgrid) and I aim to insert an "X" into the expand/collapse button. After several attempts, I successfully added the "X" icon to all grids using this code: .ui-icon-circle-trian ...

Error encountered in Three JS Drag Controls: Unable to assign value to property 'x' as it is undefined

I've been trying to drag the spheres around the scene using drag controls that should be activated when the "m" key is pressed. However, I keep running into an issue where the objects don't move and I receive an error message saying "Uncaught Typ ...

MySQL conditions in game development

When a player transfers an item to their character, the item type is communicated to the server. In scenarios where a player equips an armband with the type "bracelet," I want it to attempt placing the item ID in the leftbracer column of the game_moblist ...

Employing HTML5/CSS3 for classic image animation through traditional Sprite animation techniques

Currently, I am exploring the use of a sprite sheet for animation purposes. Rather than using canvas, I have opted for the HTML5/CSS3 method of displaying images on the screen. However, I have encountered a potential obstacle at the start of this process. ...

ReactJS did not get the expected function type for the onClick event listener, instead receiving an object type

I am encountering an issue where I expected the onClick event listener to be a function but instead got an object type error. Can someone offer guidance on how to resolve this problem? Below is a snippet of my code: render_detail_options = () => { ...

Adjusting Screen Size for Lottie Animation in React.js

I need assistance with resizing a lottie animation component on my website's landing page to set its display to none on mobile devices. How can I achieve this? See the lottie component code below: import React from "react"; import Lottie fr ...

JavaScript Autocomplete Validation

I'm working on a web page that has two TextBoxFor fields with Javascript autocomplete. The first field, ClientUser, receives a response that includes both an integer and a string. I need to compare this integer with another integer field on the page, ...

Is it possible to implement a personalized "Loading..." div in Fancybox 2?

Despite searching extensively, I have not been able to find a solution or any reference in the documentation at : Is there an option to substitute my own custom div in place of the loader GIF during the loading process when Fancybox is waiting for content ...

Is it possible to display an element within a designated div using jQuery?

I am working with an element that I want to display in the middle of the page using a for cycle so it can be populated with the correct information. This particular element is hidden but should appear on hover. However, it doesn't look very aesthetica ...

Creating sequential hover animations with CSS in HTML

I have a total of four divs that I want to hover continuously, one after the other. Here is the code I am currently using: #rij1 .content-overlayz, #rij1 .content-details { animation-duration: 2s; animation-name: stepped-pulse; animation-iterati ...

What could be causing the issue of CSS Styles not being applied to an Angular 2 component with Vaadin elements?

Currently, I am immersed in the tutorial on Vaadin elements using Angular 2 that I stumbled upon here In section 5.3, Styles are applied to the app.component.ts as shown below import { Component } from [email protected]/core'; @Component({ select ...

Deleting a li element within an AJAX response function can be accomplished by targeting the specific

I am attempting to remove the li element that is the parent of the clicked a element. Here is the code I am using: function vanish(id_arg){ $.ajax({ url: "/vanish/", type: "POST", data: {id_to_delete: id_arg}, ...

"How to retrieve data from a nested object in MongoDB by referencing variables

I am facing an issue with accessing nested objects using a variable in the npm package mongojs. Despite my efforts, the code snippet below is not working as expected: let userID = req.user._id, marketName = req.body.marketName, itemNam ...

Calculate the overall length of a specified time interval using Node Js

My task involves calculating overtime based on work start and end times. We are looking to calculate overtime hours that fall outside of the regular work schedule. For example, the regular work timings are from 10:00 AM to 07:00 PM Overtime needs to be ...

How can I utilize a service for monitoring user data and ensuring that $watch() functions properly?

I'm a beginner when it comes to AngularJS and currently working on building a website that has a navigation bar dependent on the user's login status. My approach involves using a state model design with the Nav controller as the parent state for ...

Styling a div box

I've been experimenting with CSS on a div for a while now, but I'm still struggling to replicate the image below. If anyone can offer some guidance, it would be greatly appreciated. I'm looking for a solution involving a div or another elem ...