Incorporating a Thumbnail Image with a Stylish CSS Border

I'm attempting to replicate the course listing thumbnail image layout used by Lynda.com (view example here). However, I'm unsure how to integrate the image within my current code setup found here. Specifically, I'm puzzled about the ideal dimensions for the image and handling resizing if the description extends beyond the border. Any advice on how to achieve this?

If push comes to shove, I'll keep descriptions concise. Moreover, I understand that enlarging the image with an elongated description will disrupt consistency with other thumbnail images on the page.

HTML:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"

<a class="course_list_link" href=""> 
<p class = "course_list_border"> 
  <strong> Title </strong> <br/> <br/>    
  description <br/> <br/>  
  skill_level  &emsp; 
  date &emsp; 
  Views: views &emsp; 
subject </p> </a>

CSS:

.course_list_border{
    border-style: solid;
    border-width: 1px;
    border-color: #DCDCDC;
    padding: 10px;
    word-wrap: break-word;
}

.course_list_border:hover{
    background-color: #F8F8F8;
    cursor: pointer;
}

.course_list_link{
    color: black;
}

.course_list_link:hover{
    text-decoration: none;
    color: black;
}

body {
    min-height: 400px;
    margin-bottom: 100px;
    margin-top: 0%;
    clear: both;
    padding-top: 55px;
    font-family: 'Roboto', sans-serif;
    font-size: 16.5px;
}

Answer №1

I have implemented some modifications to your CSS and HTML files

.course_list_border{
border-style: solid;
border-width: 1px;
border-color: #DCDCDC;
padding: 10px;
word-wrap: break-word;
}

.course_list_border:hover{
background-color: #F8F8F8;
cursor: pointer;
}

.course_list_link{
color: black;
display: inline-block;
width: 30%;
}

.course_list_link:hover{
text-decoration: none;
color: black;
}

body {
min-height: 400px;
margin-bottom: 100px;
margin-top: 0%;
clear: both;
padding-top: 55px;
font-family: 'Roboto', sans-serif;
font-size: 16.5px;
}
<a class="course_list_link" href=""> 
  <p class = "course_list_border"> 
<strong> Title </strong> <br/> <br/>    
description <br/> <br/>  
<img src="https://via.placeholder.com/200X150" alt="Lights" style="width:100%"/>
skill_level  &emsp; 
date &emsp; 
Views: views &emsp; 
  subject </p> 
</a>

Since you are using Bootstrap, consider utilizing the pre-existing classes for creating image thumbnails as well

https://getbootstrap.com/docs/4.0/content/figures/

Answer №2

In most cases, it's recommended to divide all items into elements rather than combining them into a single paragraph. For instance:

<style>
   a.course_list_link {
      display: block;
      width: 300px;
      border: 1px solid #DCDCDC;
      border-radius: 5px;
      text-decoration: none;
      font-family: 'Roboto', sans-serif;
      transition: all, 0.3s, ease;
   }
   
   a.course_list_link:hover .thumbnail {
      filter: grayscale(50%);
   }
   
   // Other CSS styles go here

</style>

// HTML structure for the course list item goes here

Furthermore, I prefer setting thumbnails using CSS. This ensures consistent cropping even if thumbnail sizes change. However, it's essential to avoid oversized images to maintain fast page loading times; hence, creating proper thumbnails is crucial.

As a helpful tip, it's good CSS practice to use hyphens instead of underscores in class names, such as changing .course_list_link to .course-list-link.

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 isn't my HTML list showing up on Firefox mobile browsers?

I am using jQuery mobile version 1.4.2. Here is the code snippet from my page. HTML <ul data-role="listview" class="ui-nodisc-icon ui-alt-icon"> <li><a href="#" >Real Estate in San Jose</a></li> </ul> CSS .ui-list ...

Adjust the GTK3 tooltip color exclusively for Eclipse when it is operating on Ubuntu

I am using Eclipse Mars on Ubuntu 15.04 and looking to customize the GTK3 tooltip fg/bg color specifically for Eclipse without impacting other applications. I have come across instructions for changing this color system-wide, but I need guidance on how t ...

Can you please explain what shape-id denotes and provide guidance on locating it within a CSS file?

I have a question that may seem trivial to experienced web developers - what exactly is "shape-id"? For example, in the code <hr shape-id="2">. I'm currently attempting to change the color of the horizontal lines (hr) on my website, but I can& ...

I'm noticing some significant differences in the appearance of my website when using Firefox and I can't seem to

This is my website While the site looks almost perfect in Chrome, there are some display issues in Firefox. In Firefox, all text appears centered on the page rather than within the divs where it should be. Additionally, a filter problem causes every div t ...

Looking to find a way to compare two CSS class attribute values using XPath?

After reviewing the answers to the questions regarding how to target elements with multiple classes, I came across this solution: //div[contains(@class, 'class1') and contains(@class, 'class2')] However, I have concerns that this meth ...

Drawing intersecting lines on a javascript canvas and clearing them using the lineto method

I am working with a canvas where lines are drawn based on mouse movement. I am trying to achieve the effect of the line only lasting for a few seconds before disappearing, similar to swirling a ribbon with a set length. I have been using lineTo to draw the ...

Is it conceivable that Rails may be rendering HTML at a slower rate compared to static

When using a Rails layout, you can include HTML tags to render images like this: <%= image_tag("logo.png", :alt => "Sample App", :class => "round") %> This will generate the following HTML code: <img alt="Sample App" class="round" src="/i ...

Steps for adding buttons in a popover

I've been attempting to embed HTML attribute buttons into a popover in Bootstrap 5 using JavaScript. My goal is to create a clear button with the following function: However, the button is not displaying, only the text within the popover. https://i ...

An HTML element becomes invisible when its display property is set to none using CSS

One of the issues I'm facing is with a div element that should be hidden by default using display: none, but for some reason, the CSS statement seems to be ignored. In my project, there are three key files: index.html: This file contains all the bu ...

Use CSS to mimic the :hover functionality for touchscreen devices

I am struggling to get this piece of code to function correctly, $(document).ready(function() { $('.hover').bind('touchstart touchend', function(e) { e.preventDefault(); $(this).toggleClass('hover_effect'); }); ...

Execute a PHP script upon button click without the need to refresh the page

I'm facing an issue with integrating PHP and JavaScript. Objective: To execute a .php script when the event listener of the HTML button in the .js file is triggered without causing the page to reload. Expected outcome: On clicking the button, the PH ...

Extracting URL from HTML automatically

I'm in the tedious process of copying multiple URLs from a website, which involves clicking on numerous links and then pasting the URL (along with other information) into an Excel file. This method is incredibly time-consuming, especially since I have ...

Issues encountered when using Vue Transition in conjunction with v-autocomplete

Attempting to conditionally display or hide a selection text field using Vue's Transition feature, but experiencing an issue where the text field appears and disappears without any transition effect. <template> <Transition v-if="is ...

Is it possible to adjust the height of a panel in Jquery Mobile 1.4.5?

Currently working on a jqm project that is specifically for mobile devices. In this project, I have implemented two panels - one set to push and the other overlay. While one panel is positioned in the left corner of the screen, the other is located in the ...

How can I stop Javascript from running on a website?

I have come across a question that has been asked previously, and while I found the answer to be helpful (view here: https://it.stackoverflow.com/a/550583), it doesn't quite provide the desired solution. Here's some background information: I am ...

Trouble with ASP.NET Master Page CSS Rendering Incorrectly

My CSS seems to be causing some trouble as the DIVs are not aligning as they should. Instead, they are just wrapping around the text and not adjusting the page layout properly. Here is an example of my CSS: body { height: 95%; width: 100%; ma ...

Identify and mark labels when hovering over them

Hello everyone! I'm completely new to this, so please be gentle :). Apologies in advance if my terminology is off. I have zero experience with HTML, but I landed here from working with FileMaker. Currently, I am developing a FileMaker database for my ...

Element misbehaving after a certain point

I'm encountering an issue with a piece of code that is not working as expected. The problem seems to be specifically with the after element. The desired behavior is for two lines to draw from the top left corner and the bottom right corner when hoveri ...

Having trouble with CSS :before pseudo-element and sibling selector?

Looking for a CSS solution to change the appearance of a triangle when the .hide class is activated within my markup. I attempted using a pseudo-element like so: summary:before { content: '\25BC'; } summary:before + .hide { con ...

Utilizing custom template tags with script tags for componentization within Django applications

Currently working on a Django project with multiple apps. One of the main apps serves as the base, housing global elements like CSS, JS, and custom template tags (referred to as CTTs). I'm interested in creating CTTs that contain HTML and script tags ...