Displaying Tabular Data Over an Image Using HTML and CSS

I've been attempting to place this table in front of this image and it's just not working out. I understand that the table isn't perfect, it's just a simple example!

HTML

<section>
  <div class="image-wrapper">
    <img src="img/animesea.png" alt="animeb-image" class="picimage">    
    <table>
      <tr>
        <td>a</td>
      </tr>
    </table>
  </div>
</section>

Thank you

Answer №1

One possible approach is to implement the image as a background-image, in line with @SVK's suggestion. An alternative method involves placing the img tag and the table tag within separate divs and applying position: absolute to both elements. Check out this example on jsFiddle.

Another option is to utilize z-index and positioning techniques. Take a look at this jsFiddle demo. While your desired outcome may not be entirely clear, it seems that setting the image as a background image, as suggested by @SVK, might align with your intentions.

Answer №2

You have the ability to utilize CSS styling in order for the background image to adjust automatically based on the size of the table.

Here is the code snippet:

.tableBckImg
{
    background:url(http://www.placehold.it/300x300);
    background-repeat:no-repeat;
    background-size:100% 100%;
}
<table cellspacing="0" cellpadding="0" border="0" class="tableBckImg">
    <tr>
      <td width="50" align="center">1</td>
      <td width="50" align="center">2</td>
      <td width="50" align="center">3</td>
    </tr>
    <tr>
      <td width="50" align="center">4</td>
      <td width="50" align="center">5</td>
      <td width="50" align="center">6</td>
    </tr>
    </table>

You can modify the number of rows and columns to observe how the background image expands or shrinks accordingly, as demonstrated in this fiddle example.

In the provided example, the background image has dimensions of 300x300 pixels.

Answer №3

Take a look here for some inspiration.

  <!DOCTYPE>
    <html>
    <style>
.image-wrapper 
      { 
        width:650px;
        height:488px;
        background: url("http://stuffpoint.com/sea-and-beach/image/56782-sea-and-beach-anime-sea-pic.jpg") no-repeat;
        background-size:contain; 
        padding:5px; 
        margin:auto;
      }
table 
  {
    width:650px;
    height:150px;
    border:2px solid yellow;
    color:white;
    background-color:rgba(0,0,0,0.5);
    text-align:center;
    padding:2px;
  }
th  
  {
    border:1px solid yellow;
    color:white;
    font-size:20px;
  }
td
 {
    border:1px solid yellow;
    color:white;
 }
   </style>
      <body>
      <section>
          <div class="image-wrapper">
            <table>
                <th colspan='3'>Names and Ages</th>
                      <tr>
                        <td>First Name</td>
                        <td>Last Name</td> 
                        <td>Age</td>
                      </tr>
                      <tr>
                        <td>Eve</td>
                        <td>Jackson</td> 
                        <td>54</td>
                      </tr>
                      <tr>
                          <td>John</td>
                          <td>Smith</td> 
                          <td>74</td>
                      </tr>
            </table>
          </div>
     </section>
    </body>
   </html>

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

The CSS grid-template-area feature is not functioning properly in web browsers

Struggling with creating a responsive CSS grid layout for different screen sizes. I want to have five divs on desktop screens and adjust the layout for smaller screens. As a newbie in web development, I'm finding it challenging to get it right. .fir ...

CSS Trick: How to Clear Content in a 3-Column Div arrangement

I've been struggling to clear the content below my three div columns, each consisting of a span with centered text and a textarea. It seems that the issue arises from the floating div tags without proper clearing. When viewed in Firefox, the next ele ...

What is the best way to switch between two icons using boot-strap and jQuery without the use of buttons?

Is there a way to make it so that clicking on the heart icon hides it and shows the filled heart icon instead using jQuery? I am struggling to figure out how to reference the other icon in my function. This is just a rough idea of what I want to achieve. ...

variable identifier looping through elements

I'm attempting to assign a dynamic ID to my div using ng-repeat. Here's an example: <div id="$index" ng-repeat="repeat in results.myJsonResults"> <div id="$index" ng-click="saveID($index)" ng-repeat="subRepeat in results.myJsonResul ...

Switching colors after uncovering text using JavaScript

I'm striving to achieve specific results with my code, but I'm having trouble pinpointing what exactly I'm doing wrong. Any guidance on how to correct my approach would be greatly appreciated. Currently, I've created rows that can be c ...

How to prevent click events and still enable scrolling within a DIV using CSS/JS

Basically, I am looking to enable scrolling within a DIV while also disabling click events. Any suggestions on how this can be achieved? Appreciate any help! ...

Listening to a song on a webpage while filling out the online form

Seeking advice on integrating audio file selection in form: <form ....> <input type="file" name="file-main" id="file-main" class="inputfile inputfile-3" multiple/> <audio preload="none" src=""> // excluding submission buttons for brevi ...

Encountering a 404 error in Flask when using a '?' in a redirect

After configuring a payment service on my Flask web app, I encountered an issue where the successful payment processing redirected me to a specific URL. However, upon reaching the URL, I received an error code 404. Strangely, when I removed the "?" from th ...

Strong tags are not functioning properly within paragraph tags in Firefox

It has come to my attention that when I insert <strong> into a <p>, the text does not appear bold. This issue seems to only occur in Firefox, as Chrome and Safari display it correctly. However, when I place <strong> inside a <li>, e ...

Top method for determining available space for images positioned randomly within a specified area

Currently, I am utilizing HTML's Canvas tag to design a word cloud that is randomly generated. My main focus is on finding the most effective way to determine where there is sufficient blank space within a specified area to accommodate a word. At the ...

Eliminating extra space below the footer using CSS in Wordpress site

After recently updating my website, I am struggling with some of the finer points. It's worth noting that I lack experience in web development, despite working in the software field; I am trying to broaden my knowledge. In particular, I have noticed ...

Assistance with Parallax Mouse Movement, Using JQuery, HTML, and CSS

As a newcomer to JQuery, I decided to experiment with creating a parallax background effect using the mousemove function. By utilizing event.pageX to generate a variable for adjusting the background position, I was able to achieve the desired result. Alth ...

Extracting textual information from Wikipedia through iframes?

Currently, I am working on a website project utilizing Squarespace. This site will feature multiple pages dedicated to individuals who have reached a level of notability worthy of having their own Wikipedia page. With over 150 pages planned, manually writi ...

saving information to a MySQL database after receiving data through HTML forms

I'm currently facing an issue with referencing the database to store new user information on my website. Below is an example of the HTML and PHP form we are utilizing: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/htm ...

Add to the end just before the final element when generating dynamically

var creatediv = document.createElement("div"); var text1 = '<input id="attribute1" type="text" placeholder="Attribute" /> $(creatediv).append(text1); var text3 = '<input id="attribute3" type="text" placeholder="Attribu ...

Tips for retrieving the selected option from a dropdown menu

I have a dropdown menu with checkboxes that can be selected using SumoSelect. Here is the markup for the dropdown menu: <select multiple="multiple" name="somename" id="uq" class="select"> <option value="volvo">Volvo</option> <o ...

Using Javascript to convert numerical input in a text box into its corresponding letter grade

I have been working on this code, but I am facing some issues with displaying the result. My goal is to input a number, such as "75", click a button, and have the bottom textbox show the corresponding letter grade, starting with "C" for 70-80 range. Here i ...

When attempting to transmit data to the server, an error message pops up in the DevTools console of the browser. The error is displayed as "Network Error at create

I am currently utilizing React JS for the front end of my web application and PHP for the back end. When I try to send data to the server upon clicking a button on the webpage, I encounter the following error: Network Error at createError (createError.js:1 ...

Renewing Masonry and JQuery

Currently implementing Masonry from into a project aimed at creating a timeline effect for user interaction. The goal is to automatically refresh the page at intervals (every 10 seconds during testing), but encountered an issue. Upon initial load, the ge ...

What is the CSS code to modify the color of an SVG ::marker?

I am looking to change the color of an SVG li::marker based on the font color. I attempted using fill="currentColor" but it did not work as expected. Any suggestions on how to resolve this? li::marker { content: url("data:image/svg+xml,% ...