Ways to limit the height of table rows

I have designed a TABLE as shown below:

<html>    
<body>
    <table border="0" cellspacing="0" cellpadding="1" width="100%">
        <colgroup>
            <col span="1" style="width:5%">
                <col span="1" style="width:70%">
                    <col span="1" style="width:25%">
        </colgroup>
        <tr>
            <td colspan="2">
                <div style="width:100%; box-shadow: 1px 1px 1px #cfcfcf; border-radius:10px; color:black; border:1px solid #e5e5e5; min-height: 100px;">Sample Text 1</div>
            </td>
            <td rowspan="5" class="loginform">
              <fieldset style="border-radius: 5px; padding: 5px;">
                        <legend>Template</legend>
                        <ul style="padding: 10px;">
                            <li>one</li>
                            <li>Two</li>
                            <li>Three</li>
                            <li>Four</li>
                            <li>Five</li>
                        </ul>
                    </fieldset>
            </td>
        </tr>
        <tr>
            <td>val</td>
            <td>
                <div style="width:100%; box-shadow: 1px 1px 1px #cfcfcf; color:black; border:1px solid #e5e5e5; min-height: 80px;">1 Only</div>
            </td>
        </tr>
        <tr>
            <td>bal</td>
            <td>
                <div style="width:100%; box-shadow: 1px 1px 1px #cfcfcf; border-radius:10px; color:black; border:1px solid #e5e5e5; min-height: 80px;">2 only</div>
            </td>
        </tr>
        <tr>
            <td>nal</td>
            <td>
                <div style="width:100%; color:black; box-shadow: 1px 1px 1px #cfcfcf; border-radius:10px; color:black; border:1px solid #e5e5e5; min-height: 80px;">Both 1 and 2</div>
            </td>
        </tr>
        <tr>
            <td>dul</td>
            <td>
                <div style="width:100%; box-shadow: 1px 1px 1px #cfcfcf; border-radius:10px; color:black; border:1px solid #e5e5e5; min-height: 80px;">Neither 1 nor 2</div>
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
        </tr>
    </table>
</body>    
</html>

For this table, I want to make sure that the height of the Template (section on the right-hand side) is always equal to the combined height of five rows in the table. If there is more content inside the template, it should be displayed with a scroll bar but should not exceed the height of the five rows in the table. Any suggestions on how to achieve this?

Answer №1

To ensure proper alignment, it is necessary to establish a fixed height.

For reference, take a look at the following example:

http://jsfiddle.net/8tFnG/

<fieldset style="border-radius: 5px; padding: 5px;height: 450px; border: solid 1px red;">

Answer №2

If you have knowledge of the heights of the five rows located on the left side, you can control the height of your "Template" fieldset by applying a straightforward CSS rule:

max-height: 400px; overflow: hidden; overflow-y: scroll;
. In this case, 400px represents the combined height of the five rows in the table; the overflow is set to hidden with scrolling available along the y-axis. Give it a try:

.loginform fieldset{
    height: 400px;
    max-height: 400px; 
    overflow: hidden;
    overflow-y: scroll;
}

Alternatively, another approach would involve using JavaScript. By determining the height of the table that holds the five rows, you could then dynamically adjust the height of the "Template" fieldset upon page loading.

I trust this information proves beneficial for your needs.

Answer №3

Include the CSS property position:fixed in the style of this element

Answer №4

You should test out this CSS code:

<style>
    section{ width: 600px;overflow-x:hidden;}
</style>

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

Issues arise with AJAX authentication request

Currently, I'm working on incorporating a basic login form with an AJAX request that forwards the user to a page for querying my database. Depending on the results, the user is then redirected to the main index page or prompted back to the login form. ...

Modal obstructing BsDatePicker

<!-- The Server Modal --> <div class="modal" id="serverModal"> <div class="modal-dialog" style="max-width: 80%;overflow-y: initial !important;" > <div class=" ...

Is it possible to define the sequence of wrapped items in CSS flexbox?

I am using a <div> with CSS flex to maintain responsiveness. I want to control the order in which elements are wrapped. For instance, I need 1 - 2 - 3 To be rearranged as 1 3 2 Once fully wrapped. Here is my current code: https://jsfiddle.net/ ...

PHP interjecting a loop

Below is a loop that needs to be modified: <?php foreach ($this->item->extra_fields as $key=>$extraField): ?> <?php if($extraField->value != ''): ?> <div class="<?php echo ($k ...

Enhancing user experience with CSS dropdown menu animations

I've been working on adding a dropdown transition to my menu, but I can't seem to get it right. Can anyone point out where I'm going wrong or what needs to be added for the transition effect on the dropdown menu? Here is the CSS and HTML cod ...

Tips for adding style to a group of SVG elements:

I currently have an array of .svg icons, each with unique properties that I need to customize: <svg width="24" height="24" viewBox="0 0 24 24"> ... </svg> import styled from 'styled-components'; import Github from 'assets/git ...

Switch between every other pair of table rows, then repeat with the following two pairs

I am attempting to create a table with alternating row colors of green and yellow in sets of two. I have been using :nth-child but it is not working correctly. My table is automated using Angular 6 and styled with Angular Material 6. If you would like to ...

Obtain HTML tags from RSS CDATA section

Is there a way to extract HTML tags from a CDATA tag in an RSS feed? I have utilized a basic jQuery function to retrieve the JSON object from the RSS, below is my code: $.get("someURL", function(data) { console.log('InGet'); ...

Encountered an unforeseen token "<" that is causing the server to return a 404 HTML page instead of the intended .js

I am currently developing a to-do list application using Node.js Express and EJS. In the app, I have implemented a filtering functionality with a URL path of "/filter/query". Based on the selected category (either "lists" or "lastupdated"), the app filters ...

Ensure JSF encodes special characters in Unicode

Can JSF be forced to escape special characters using the unicode method &#228; instead of the named entity approach &auml;? Issue: Some older mobile devices (such as a HTC Desire with Android 2.3.4) fail to display a page containing named entities ...

Tips for altering the color of an activated Bootstrap dropdown toggle

When the Dropdown menu is open, I would like to customize its default colors. Specifically, I want to change the border color and background using CSS. https://i.sstatic.net/vKwLE.png Below is the HTML code snippet: <div class="row menu"> <ul ...

What is a method for capturing the value of a nested input element without requiring its ID to be

Currently, I am facing a challenge in selecting the value of an input box from a user-generated ordered list of text boxes and logging its value to the console. It seems like I cannot find a way to select the value of a child's child element when the ...

What's the best way to iterate through multiple objects within <td> tags using Vue.js?

I have an Array filled with multiple Objects, and now I am interested in iterating through each object as a <tr> within a <table>. I have successfully achieved this. However, some of these objects might contain nested objects. In such cases, I ...

Issues with WebDriverWait Syntax

Currently using OS X and Python version 3.5.1. I am curious about the correct way to use WebDriverWait to locate an xpath element and then click on it once the webpage has fully loaded. WebDriverWait(driver, 10000).until(EC.presence_of_element_located(dr ...

How can I dynamically adjust the stroke length of an SVG circle using code?

In my design project, I utilized Inkscape to create a circle. With the fill turned off, only the stroke was visible. The starting point was set at 45 degrees and the ending point at 315 degrees. After rotating it 90 degrees, here is the final outcome. < ...

The Bootstrap navigation bar vanishes when viewed on mobile devices

I've integrated Bootstrap 5 with my navbar, but when viewed on a mobile device, the buttons disappear. Even hovering over them doesn't display anything. Is there a solution for this issue? Below is the code snippet: <nav class="navbar na ...

Images that are see-through or translucent

Can someone confirm if Internet Explorer supports transparent PNGs now? How about Chrome? ...

Adding a pair of labelled angled columns in a container that spans the full width is a breeze

I'm in pursuit of this: https://i.sstatic.net/HYbC1.jpg What I currently possess is: <div class="row slantrow"> <div class="row slant-inner"> <div class="col-md-6 slant-left"> <p>text</p> ...

Tips for designing rainbow-themed elements (hyperlinks) using CSS to incorporate multiple colors

When customizing link styles in D3.js, it's common to adjust the color of the links. For instance, in the code snippet below, I've created thick links with a width of 10 and colored them grey. link = svg.append("g") . . . .style("stroke", "grey" ...

How is it that the bird is able to navigate around the ledges without any collisions?

I'm currently developing a flappy bird game using phaser.js. The issue I'm facing is that the player doesn't collide with the ledges in the game. Also, I would like to know how to implement camera movement (similar to Flappy Bird). Any addi ...