Tips for implementing the CSS overflow attribute on targeted content

I am setting the overflow property for the <form> element, which contains a <legend>. The issue is that the overflow affects the entire form, including the legend, when I actually want it to apply only to the table within the form. Essentially, I have a form with a legend and a table, and I only want the overflow to be applied to the table.

Here is the link to my fiddle:

http://jsfiddle.net/raghavendram040/z6jRX/1/

This is my HTML code:

<form>
<fieldset>
<legend>&nbsp;&nbsp;&nbsp;Menu</legend>
<table id="tab">
    <tr>
        <td>abc</td>
    </tr>
    ...
    </table>
</fieldset>

And here is my CSS code:

form{
  border: 1px #6A6A45 solid;
  border-radius:6px;
  height: 200px;
  overflow: auto;
  background-color:#efefef ;
  margin-bottom: 17px;

}

I tried applying overflow specifically to the table like this, but it did not work:

#tab{ overlow: auto }

Can anyone help me figure out how to correctly apply the overflow property only to the table in this case?

Answer №1

Enclose your table within a div tag and set overflow property for the div.

Check out this fiddle!

Here is the HTML code:

<form>
<fieldset>
    <legend>&nbsp;&nbsp;&nbsp;Menu</legend>
    <div id="scroll">
        <table id="tab">
            <tr>
                <td>abc</td>
            </tr>
          ...
        </table>
    </div>
</fieldset>
</form>

And here is the CSS code:

#scroll {
    overflow: scroll;
    height: 140px;
}

Answer №2

To enclose your table, simply place it within a div:

View the Live Demo

<div id="wrapper">
    <table>
        <tr>
            <td></td>
        </tr>
    </table>
</div>

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

How can I transmit information to and retrieve information from a node.js server?

When working with React code, I encountered issues with sending 'post' and 'get' requests. After some investigation, it seems that the problems lie within my server-side code. Overall Setup const express = require('express') ...

how to keep form submission on hold until animation completion with jQuery

My website features a page animation where the document slides to the left when the user leaves the page. However, I am facing an issue with a form on the same page. I would like the form submission to be delayed until the animation is complete (e3ms?). D ...

How can I use ReactJS to find the nearest five locations in order from closest to farthest?

I'm in the process of creating a website for searching nearby locations. I am facing an issue where I want to display the 5 closest locations from my current location in ascending order, but I keep getting the same location result. I need these locati ...

Execute supplementary build scripts during the angular build process

I've developed an Angular application that loads an iframe containing a basic html page (iframe.html) and a Vanilla JavaScript file (iframe.js). To facilitate this, I've placed these 2 files in the assets folder so that they are automatically cop ...

Transferring JSON data using DWR (Direct Web Remoting)

Utilizing DWR for AJAX calls in my project involves the conversion of JavaScript objects to Java objects by analyzing the Java class. My goal is to send and receive a JSON-like structure through DWR. For example: JavaScript Object: { "name" : "TamilVe ...

Transmit information from a JavaScript AJAX function to a JSP page

My current goal involves a user clicking on a link on the home page, let's say /home.jsp. Upon clicking this link, I extract the value and use it to call a RESTful resource that interacts with a database and returns a response. The communication with ...

What causes the variation in default margin between React and traditional HTML?

There seems to be a difference in margin between <button> elements when rendered by React compared to plain HTML. Plain HTML adds a small margin between the buttons, while React removes it completely. Does anyone have an explanation for this discrep ...

Adding HTML content to routes in ExpressOrEnhancing routes

Recently, I've been working with a basic index.html file. My goal is to have the routes file append an HTML button when requested by the browser without actually modifying the original file. This may seem like a peculiar idea, but my intention is to c ...

Which framework should be used: client-side or server-side?

I am working on a project similar to craiglist, where users can post announcements for everyday items like cars and flats. I have already developed a significant portion of the backend using a RESTful API in three-tier architecture with Java, connecting to ...

When setting the margin to auto, it perfectly centers elements on servers and IE, but on Chrome off the server, it appears to be aligned to the

There seems to be an issue with the display of my page in Chrome - it starts at the middle and ends on the right side. However, when I view it on my server or try it on Internet Explorer 11, it appears centered. Why is that? This problem only arose after ...

Easy jQuery image that smoothly fades in and out

Can anyone recommend a script that allows for creating a slideshow where images fade in and out, rather than sliding left and right? I have a list of images below that I would like to use for the slideshow. <ul class="slideshow"> <li><im ...

How can I prevent right-clicking with Ctrl+LeftMouseClick in Firefox on MacOS?

I'm looking to implement a shortcut using Ctrl+LeftMouseClick in my React project. It functions perfectly on Chrome on my Mac, but in Firefox the shortcut initiates a right mouse click (event.button = 2). I believe this may be due to MacOS's Rig ...

Conditions are in an angular type provider with AOT

I am facing an issue with my Angular project that is compiled using AOT. I am trying to dynamically register a ClassProvider based on certain configurations. The simplified code snippet I am currently using is below: const isMock = Math.random() > 0.5; ...

Error: The code is unable to access the '0' property of an undefined variable, but it is functioning properly

I am working with two arrays in my code: bookingHistory: Booking[] = []; currentBookings: any[] = []; Both arrays are populated later in the code. The bookingHistory array consists of instances of Booking, while currentBookings contains arrays of Booking ...

Trigger a function with AngularJS when the page loads

I'm currently studying AngularJS. I have a set of article tags and want to display each article page without refreshing the page when a button is clicked. This website consists of only one page. The issue I am facing is that despite trying to call myF ...

Obtaining the latest state within the existing handler

In my React application, I have a handler that shuffles the state entry data: state = { data:[1,2,3,4,5] }; public handleShuffle = () => { const current = this.state.data; const shuffled = current .map((a: any) => [Math.random() ...

What mistake have I made in my JavaScript code?

Data Entry: let name = 'Sophia'; console.log('Hello, my name is', + name + '.'); Result: SyntaxError: Unexpected identifier ...

Is there a way for me to automatically update a webpage every 5 minutes, beginning at 8:01 a.m., and subsequently at 8:06 a.m., and so forth?

<html> <head>Harshal</head> <script> var limit="5:0" var doctitle = document.title var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 function beginrefresh(){ if (parselimit==1) window.location.reload ...

I am currently experiencing difficulties with uploading an image from the admin panel in Magento 1.9. Instead of receiving the expected response, I am

I encountered an error while trying to upload a file in Magento for a product image. When I click on upload, an error is displayed during the file upload process. Upon further investigation in the product.js file for item response, I noticed that HTML is b ...

Tips on displaying zero values in tooltips on ApexCharts line graphs

I have integrated ApexCharts to generate line graphs within my application. However, I encountered an issue where the tooltip still appears even when a series has a zero value, without displaying any information. Is there a method to customize ApexCharts i ...