Expand the image background to fit within a div container

Below is the code snippet I am working on:

<div id="intro_section_upper" >

                <%= image_tag("video_background.jpg", :id=>"video_bg") %>

                <div id="video_table_main" >

                    <table class="video_table">

                        <% count = 0 %>
                        <tr>
                        <% @f_videos.each do |f_video| %>

                            <td><div class= "video_cell">
                                <%= f_video.name %> </br>
                                <%= image_tag(f_video.thumbnail_url, :class => "video_thumb") %>
                            </td></div>

                            <% count +=1 %>

                            <% if count % 4 == 0 %>
                                </tr>
                            <% end %>

                        <% end %>

                    </table>

                </div>

I have also created the following CSS rules:

#intro_section_upper
{
    position: relative;
    width: 1024px;
    min-width: 1000px;
    min-height: 600px;
    margin: 150px auto;

    color: #333399;
    border-style:solid;
    border-width:1px;
    border-color:#3366CC;
    border-radius: 15px;

    background-color:#3366CC;   
    font-family: 'Arial';
    font-size:16px;

}

/* Float fix */
#video_table_main {

    height:600px; overflow:auto; 

    }

img#video_bg
{
    width:100%;
    height:100%;
}

/* Individual Video Data Cell Formatting */
.video_cell 
{   
    color: #C0C0C0; font-weight:bold; font-size:1em;
}

.video_thumb
{
    vertical-align:text-top;
    width: 180px;  
    height : 180px; 
}

I would like the thumbnail table to be positioned above the background image instead of below it. Additionally, I am looking for a way to round the border of the image to match the rounded corners of the container. Any suggestions on how to achieve this?

Answer №1

Have you considered setting your image as the background of your div?

#intro_section_upper{
   background-image:url("video_background.jpg");
   background-repeat:no-repeat;
}

If you have a reason for not using a background image, another option could be to set it like this:

#video_table_main{
   position:absolute;
   top:0;
   left:0;
}

I hope that suggestion is helpful!

Answer №2

Learn the art of creating rounded borders with CSS!

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

What is the best way to combine PHP with HTML in your code?

I am looking to display data from a database in a table format. Additionally, I want to include images sourced from the same database. Using AJAX, I have a function called getPosts that fetches data from getPosts.php and populates a table with it. Althou ...

Create a hover effect on HTML map area using CSS

Is it possible to change the background color of an image map area on hover and click without using any third-party plugins? I attempted the following code: $(document).on('click', '.states', function(){ $(this).css("backgro ...

"Trouble with script: external JavaScript file failing to run

The issue lies in the fact that the specified external JavaScript file is not being executed: <script src="//www.google-analytics.com/cx/api.js?experiment=YOUR_EXPERIMENT_ID"></script> Even when I try to directly access the URL, it downloads ...

Looking for assistance with aligning an image in a <td> cell that doubles as a link?

How can I center a play icon in the middle of a td cell and make the entire content clickable as a link, including the background image? I've tried various methods but can't seem to get it right without breaking the alignment. Any suggestions wou ...

Using jQuery's .on() method to dynamically add classes

Why is this method not functioning as expected? My understanding was that by assigning a class to the trigger element when it opens, I could then use that class to close it when the trigger is clicked again. // Trigger for menu $('.menu-trigger' ...

What consequences could occur in HTML if the main tag is not properly enclosed within the body tag?

Just starting out. While working with HTML, I experimented with placing the main tag outside of the body tag instead of nesting it inside as recommended by HTML5 standards. To my eye, both versions looked identical when I viewed the HTML file side by sid ...

When viewed through the Firefox browser on an Android device, the text on the webpage suddenly enlarg

I currently have the following content displayed on my website: <div style="font-size: 11px; line-height: 17px; text-align: left;"> <p>lorem ipsum etc etc</p> </div> Strangely, despite setting the font size to 11px, the te ...

Enter information to accompany your images in the description box

After browsing through numerous websites tonight, I stumbled upon this code. My goal is to create a photo upload page on Google Drive and set up a dropbox for it. I'm facing an issue where the information inputted into my placeholder box (city and ye ...

Continuous horizontal columns

Is there a way to create horizontal columns with inline-blocks, like the method described here, without having vertical gaps between items on the second line due to different heights? I want to eliminate the vertical gaps between the tiles using only CSS. ...

Issues with Gulp Autoprefixer Functionality

I'm struggling to make Autoprefixer work with Gulp. Despite using opacity, gradients, and transforms in my CSS, I can't see any vendor prefixes being added. However, everything else seems to be functioning correctly. Below is my gulp file: var ...

Strange HTML antics

On my website, I encountered an issue when trying to register without entering any information into the required fields. The errors were correctly displayed in this screenshot: https://i.sstatic.net/wrxjt.png However, after inserting random characters in ...

Is there any advantage to placing buttons within an HTML form?

What benefits are there to placing a button within an HTML form as opposed to directly in the body? <form id="viewForm" method="post"> <input id="editBtn" type="button" value="Edit" /> </form> ...

An adaptive image-based menu design that adjusts based on screen size

Although I can get it to function properly, the trouble arises when I attempt to resize it for responsiveness, resulting in a strange scaling issue. Essentially, I want the images to remain at their natural size and align next to each other seamlessly with ...

CSS: Using absolute and relative positioning within a parent element can result in elements overlapping

I want to create a box in html/css where the read more hyperlink text is positioned over the background image. The goal is to have additional text added to the description without overlapping the image. Here's an example of the current issue. Curren ...

The animation fails to function, both when hovering over and when not

ul { display: flex; flex-direction: row; align-items: center; list-style-type: none; background-color: $base-gray-t; margin: 1em; padding: .25em 0 0 0; height: 3em; border-bottom: 0.375em solid $secondary-color; overflow: hidden; ...

The functionality of the .toggle method is limited to only being effective 1.5

I'm having an issue with making an image popup using the .toggle function in javascript. It seems to work initially, but then only works partially after that. When I click on the image, it opens as expected. However, when I try to close it by clickin ...

Encase every picture within a div and add a numerical label in front of it

I'm working on a function that will wrap each image in a div and add a span label for each image. Here is the code I have written so far: $('#carousel img').each(function(index) { $(this).wrap('<div class="image"></div>& ...

Animation effect in Jquery failing to execute properly within a Modal

I have developed a small jQuery script for displaying modals that is both simple and efficient. However, it seems to only work with the fadeIn and fadeOut animations, as the slideUp and slideDown animations are not functioning properly. I am unsure of the ...

Adding a timestamp to the src URL in HTML: A step-by-step guide

Looking for a way to implement cache busting in my index.html file. Take a look at the code snippet below: <body> <app-root></app-root> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="&l ...

My DIV elements are not responding to the widths I set for them. What could be the issue?

Recently, I've been delving into the world of Flex to experiment with some unique layouts. However, I encountered an issue where my divs were not recognizing widths as expected. I attempted to set the first div of each row to 5% width so they would ...