How can I design DIVs to resemble a radio station or television schedule grid?

Check out the JSFiddle for my page with the source code included:

https://jsfiddle.net/g0kw1Le8/

Here is a snippet of the source code:

<TITLE>Hallam FM - Best Variety of Hits</TITLE>
<style>
/* CSS styles go here */

/* End of CSS */
</style>

<!-- HTML content goes here -->

</div>
    

In summary, I'm trying to achieve two things:

  • Implement a hover effect that displays presenter information and photos similar to websites like this example or this one, but with a vertical layout instead of horizontal.

  • Adjust the width of each show segment to fit the time duration (e.g., a 4-hour show should be 240 units wide). Currently, all shows appear packed without aligning properly with the time slots at the top.

I've been experimenting with different approaches but haven't been able to match the design seen in the Internet Archive link provided above. Any tips or suggestions would be greatly appreciated.

Answer №1

Transforming your design can be accomplished using the <table> element, but a more versatile and enjoyable option might be CSS grid.

By creating 24 grid columns and assigning time slots with different classes, you can achieve the desired layout.

Make sure that any supplementary information is positioned absolutely in relation to its respective item. Additionally, implement a hover effect to change the display type.

Check out this fiddle

body {
  margin: 0;
  padding: 1rem;
  background: black;
  color: lightgrey;
  font-family: sans-serif;
  font-weight: 300;
  line-height: 1.35;
}

img {
  display: none;
}

.wrapper {
  display: grid;
  grid-template-columns: repeat(24, 60px);
  grid-gap: .5rem;
}

.mins-60 {
  grid-column: span 1;
}

.mins-120 {
  grid-column: span 2;
}

.mins-180 {
  grid-column: span 3;
}

.mins-240 {
  grid-column: span 4;
}

.mins-300 {
  grid-column: span 5;
}

div[class^="mins"] {
  position: relative;
  border-top: .333rem solid white;
  padding-top: .333rem;
  cursor: default;
}

p {
  display: none;
  position: absolute;
  top: 1rem;
  border: .1rem solid white;
  border-top-width: .3333rem;
  background: black;
  padding: 1rem;
  width: 15rem;
}

div[class^="mins"]:hover p {
  display: block;
}
<div class="wrapper">
  <div>00:00</div>
  <div>01:00</div>
  <div>02:00</div>
  <div>03:00</div>
  <div>04:00</div>
  <div>05:00</div>
  <div>06:00</div>
  <div>07:00</div>
  <div>08:00</div>
  <div>09:00</div>
  <div>10:00</div>
  <div>11:00</div>
  <div>12:00</div>
  <div>13:00</div>
  <div>14:00</div>
  <div>15:00</div>
  <div>16:00</div>
  <div>17:00</div>
  <div>18:00</div>
  <div>19:00</div>
  <div>20:00</div>
  <div>21:00</div>
  <div>22:00</div>
  <div>23:00</div>
  <div class="mins-60">John Doe
    <p><img src="logo.jpg">John Doe on the late show !</p>
  </div>
  <div class="mins-300">Richard Roe
    <p><img src="logo.jpg">More OF THE BEST VARIETY of hits !</p>
  </div>
  <div class="mins-240">Hallam Fm Breakfast
    <p><img src="logo.jpg">hALLAM fm IN THE MORNING !</p>
  </div>
  <div class="mins-300">Weekday Daytimes
    <p><img src="logo.jpg">John Doe ! !</p>
  </div>
  <div class="mins-240">Jon Smith
    <p><img src="logo.jpg">John Doe ! !</p>
...

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

Connecting to particular sections on other pages

My website setup includes a page titled "news.html" that contains an iframe with fixed size. The iframe is linked to "innernews.html", which is the actual content to be displayed. I structured it this way for consistent page sizing, as the iframe prevents ...

CSS - Struggling to identify the source of unwanted horizontal scrolling?

Recently, I've been attempting to make adjustments to a responsive website that utilizes media queries. Despite my efforts, whenever the site is viewed on a mobile-sized screen, it consistently requires horizontal scrolling regardless of the screen&a ...

Div's HTML Classes are not triggering the Click Event

I'm attempting to create a custom function that will display notifications in the top right corner of my website, similar to how OS X notifications appear. Instead of relying on an external library, I am using jQuery as a resource. To house my notifi ...

"Steady layout of grid for the navigation bar and

Currently, I am in the process of developing a control panel with the use of HTML and CSS. To structure the page, I opted for a grid layout. However, I encountered an issue where the navbar and sidebar do not stay fixed on the screen despite trying various ...

Increase the size of a div to equal the combined width of two divs located directly below it

I need help aligning 3 divs so that the top div stretches to match the width of the bottom 2 divs combined. Here is an image showing the expected div positioning. I attempted to use display: table-row for the divs. <div id="main_div" style="display: ta ...

Whenever I insert an http link for FontAwesome, the icons work perfectly fine. However, when I try to host it locally,

After providing the CDN link: <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet"> The icons are displaying correctly and everything is working fine. You can view the code on ...

Are you interested in designing a bootstrap album for your homepage?

I'm currently working on designing an album-style layout similar to the examples provided below: if you look at the recent works section where you have an image on one side and text on the other, occupying the entire width of the page: or the example ...

Choose a specific cell in the table and store it in the session

I am new to working with PHP and have never dealt with sessions before. My current goal is to randomly select a table cell and save its location (x,y coordinates) in a new session. Below is the code I have so far, but I am unsure of what steps to take ne ...

Retrieve the content of a different page and store it as a variable using ajax

Is it possible to assign the content of another HTML page to a JavaScript variable? I attempted: var X = $(http://www.website.com/home).html() Unfortunately, this did not work, even though it seemed like a good idea. Can anyone provide guidance on how t ...

Fixing the error: Severity notice, there is an undefined variable called 'table'

My controller logic is as follows: public function index() { if ($this->session->userdata ( 'logged_in' )) { $condition = array( 'qes_status'=>'Y' ); $data = array(); $ ...

Utilize the Bootstrap column push-pull feature on the mobile version of

https://i.stack.imgur.com/yTBIt.png When viewing the desktop version, div A is displayed at the top of the page. However, I would like to move it to the bottom when viewing on a mobile device (col-xs). I have attempted to solve this issue myself without s ...

The line segment refuses to remain hidden beneath the h2 tag

Just getting started with HTML/CSS here! I'm trying to figure out how to keep a line directly under an h2 tag. In my code, there's an h2 tag labeled 'Instructions' followed by a div containing 3 other divs making up a line segment. By d ...

Please enter the text in the field provided at the bottom using IE10

Why is the text inside my input appearing at the bottom in IE10, while it displays in the middle on FF and Chrome? http://jsfiddle.net/PXN2e/2/ input.form-text { color: #999999; font-size: 14px; height: 30px; line-height: 30px; paddin ...

Unable to generate file with Compass

In my attempts to compile a project using compass, I have experimented with both the gui app and the command line. However, I consistently encounter the same error message in both cases: "Nothing to compile. If you're trying to start a new project, yo ...

Ways to thwart CSRF attacks?

I am currently looking for ways to protect my API from CSRF attacks in my Express app using Node.js. Despite searching on both Google and YouTube, I have been unable to find a solution that works for me. One tutorial I watched on YouTube recommended gene ...

Waiting for response in AngularJS Controller and setting callback

I have developed an AngularJS application with controllers.js and factories.js that I am excited about. However, I am facing a challenge when trying to manipulate the values within the controller (retrieved from the factories). The issue is that these val ...

Creating dynamic selection options in an HTML select tag using PHP

When retrieving category and sub-category information from an API json file, the API returns category objects with a "parent" attribute. Main category objects have a parent attribute equal to 0, and sub-category objects have the parent attribute equal to t ...

Attempting to modify the background color of an iFrame in Internet Explorer

I am experiencing an issue with my webpage where the iFrame is displaying with a white background in IE, while it shows up with a blue background in Firefox and Chrome. I have attempted various solutions to make the background of the iframe blue or transpa ...

Excessive content spilling over into the footer area due to an integrated forum feature within

We have integrated a Muut forum into our website, and it is working well when embedded in a coding block within the page's body. However, there is an issue where the sidebar of the forum gains extra features when logged in as an admin. This causes the ...

Decrease the gap between the <hr> and <div> elements

I currently have multiple div tags with hr tags in between, resulting in automatic spacing. I am looking to decrease this space. Please view the image link provided below for reference. [I am aiming to minimize the gap indicated by the arrow] Additionally ...