Margin of Contents in a Table

I have created a table within a box on my webpage. The default setting centers the table inside the box, but I want it to align with the bottom border of the box instead. Each row in the table contains two cells, each cell displaying a picture that I would like to touch the bottom border.

<html>
<head>
    <link href="design.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="box1">      
        <table width="614" border="0" cellspacing="0" cellpadding="0">
            <tr align="center">
                <td>                        
                    <img src="TL.png">
                </td>
                <td width="1" class="vertical"></td>
                <td>
                    <img src="TR.png">
                </td>                   
            </tr>
        </table>
    </div>
</body>

.box1{      
width: 614px;   
margin: 0px;
position:absolute;
border: 1px solid #d0d0d0;
padding: 20px;
border-radius: 20px 20px 20px 20px;
overflow: auto;}
.vertical{
border-right: 1px solid #d0d0d0;
width: 0px; 
height: 250px;
float: left;
box-shadow: 1px 1px 0px #ffffff;}

Could someone please help me understand how to achieve this?

Answer №1

The reason behind this issue is the presence of padding in the styling of .box1.

Currently, the value for padding is set to padding : 20px, which adds a padding of 20px to all sides. If you want to remove the padding at the bottom, you can adjust it as follows:

padding : 20px 20px 0; /* padding : top left-right bottom */ 

CSS :

.box1 {      
    width: 614px;   
    margin: 0px;
    position:absolute;
    border: 1px solid #d0d0d0;
    padding: 20px 20px 0;
    border-radius: 20px 20px 20px 20px;
    overflow: auto;
}

You can view a demonstration of this on JSFiddle.

UPDATE :
To dynamically set the height of .vertical, you can use the following jQuery snippet:

$('.vertical').each(function () {
    var currentLine = $(this),
        prevImgHeight = currentLine.prev('td').find('img').height(),
        nextImgHeight = currentLine.next('td').find('img').height(),
        lineHeight = (prevImgHeight > nextImgHeight) ? prevImgHeight : nextImgHeight;

    currentLine.css('height', lineHeight + 'px');
});

This script will adjust the height of the line based on the taller of the two adjacent img elements.

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 an alternative way to make elements overflow on top without relying on position: absolute when using overflow: hidden?

I'm currently exploring React and I'm interested in implementing an animation using react-collapsed to collapse the upper portion of a specific component. As of now, the container size is reduced to half of the child's size and overflow: hi ...

Is it possible to create a dynamic <hr /> using Flexbox?

In the midst of working on my application, I managed to achieve a simple layout. However, there is one peculiar requirement that has been eluding me for the past 2 days and now I find myself in need of assistance. Here is the current HTML code I am workin ...

How to position an absolute element beneath a fixed element

My website is experiencing a problem where the fixed header is overlapping an absolute paragraph on this page. Does anyone know how to resolve this issue? ...

Mobile device scrolling glitch

I'm currently working on my website, which can be found at . After testing it on mobile devices, I came across an issue that I just can't seem to fix. For instance, when viewing the site on a device with 768px width, you can scroll to the righ ...

Creating dynamic links between two cells of two HTML tables within an HTML email using JavaScript

A recent project requires the creation of HTML-based emails with tables for each automation script within the test automation framework. Additionally, there is a request for an extra HTML table to provide a quick overview. The cells in the first column of ...

swap out the CSS class for my own class dynamically

When I display HTML code like this <div class="btn btn-pagination"> <i class="fa fa-angle-right"></i> </div> and want to replace fa fa-angle-right with myClass when the page loads. I attempted: $(document).ready(function () { ...

The functionality of filtering a list based on the selected value from a drop-down menu is malfunctioning

When the page initially loads, there is a dropdown with the default placeholder "Select Person Type" and a checkbox list displaying all persons by default. An angular filter is used to display only the selected type of persons from the dropdown (working p ...

Using Bootstrap to create proper spacing between columns

I am having trouble adding spacing between my bootstrap columns. The automatic spacing doesn't seem to work. Is there a specific class or method I should use to create this space? <div class="row row_padding"> <div class="col-sm-4 text-cent ...

Using HTML and CSS to capture user input data and store it in an array

I've created a form that allows users to add and remove multiple fields, ranging from one to three. My goal is to retrieve the form data and store it in an array. index.html <!DOCTYPE html> <html lang="en"> <head> ...

Z-Index not functioning as expected

I've been trying to position my <h1> header on top of a light div with a background image called light.png. I used Z-index to stack them and added position:relative, but for some reason, the <h1> is not showing above the <div class=ligh ...

Retrieve the input values and arrange them neatly in a table

I am encountering an issue with extracting values from a table. My goal is to retrieve all the input values from the table, but I am finding it challenging because the number of rows in the table can vary. <table id="receiptTable" class="table table-bo ...

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! ...

The checkbox system is designed so that if all child checkboxes are chosen, the parent checkbox will automatically become selected as well

view image description hereLet's create a checkbox structure with some specific conditions: When the parent checkbox is selected, all child checkboxes should automatically get selected. If all child checkboxes are unselected, then the parent checkbo ...

Is it possible to utilize global variables within CSS properties?

I have a scenario where I need to dynamically change values in an animation. The line of code that needs modification is: clip-path: polygon(var(clip1) 0, 100% 1%, 100% 100%, 50% 100%); let root = document.documentElement; root.style.setProperty('c ...

Why won't my Nivo Slider images print? How can I make my Nivo Slider images appear on printouts?

I am having trouble printing the nivo slider (default-theme): Despite trying for a few days, I still can't figure out why it's not working. I have attempted solutions like #slider { visibility: visible; width: 950px; height: 35 ...

Pop-up message on card selection using JavaScript, CSS, and PHP

I have a total of 6 cards displayed in my HTML. Each card, when clicked, should trigger a modal window to pop up (with additional information corresponding to that specific card). After spending a day searching for a solution online, I've come here s ...

How to center align SVG with text in a unique way

Having trouble vertical aligning my inline SVG within a label. Any suggestions? This is how I've attempted it: <label for="menu-check-box">More<svg class="more-icon"><use xlink:href="#more-chevron"></use></svg></labe ...

CSS: Placing a Column below a Float Positioned Column

While performing some maintenance on a website, I noticed that one page is not displaying correctly. There is a container div for a column on the left and a container div for content on the right, both within an overall page content container. Below these, ...

Stop images from appearing transparent when placed inside a transparent div

My issue is clearly visible in this image: The div element is transparent and affecting the images inside it. Below is my HTML code: <div id="cselect" style="position: absolute; top: 99px; left: 37px; display: block;"> <div class="cnvptr"> ...

The descendant selector in CSS fails to apply changes to the element

I am struggling to modify the border of a specific descendant element and so far I have not been successful. Despite using the correct descendant selector in the HTML below, the style change is not taking effect. If anyone has any insights on what could be ...