Utilizing display:inline-block within a table: eliminating scroll bars for a cleaner look

Can someone help me with setting a span element to display as inline-block within a table cell?

HTML

<table><tr><td>

    <span class="groupName"><a href="#">small link</a></span>

    </td></tr><tr><td>

    <span class="groupName"><a href="#">really long link that should have a horizontal scroll bar</a></span>

    </td></tr></table>                    

CSS

td{
    /*Not sure what to put here*/
}
.groupName{
    display:inline-block;
    font-size:22px;
    max-width:300px;
    overflow-x:scroll;
}

My current code is causing both horizontal and vertical scroll bars on all the span or td elements. I only want horizontal scroll bars on span elements that exceed the set width. Appreciate any guidance.

Edit Apologies, here's an improved example in this fiddle http://jsfiddle.net/LxUht/1/

Answer №1

Make sure to switch from using overflow:scroll; to overflow:auto in your CSS, and don't forget to include white-space:nowrap to prevent the text from wrapping onto the next line.

.groupName{
    display:block;
    font-size:22px;
    max-width:300px;
    overflow:auto;
    white-space:nowrap
}

Check out the DEMO here

Answer №2

Give this a shot

overflow-y:hidden;

try it out

Answer №3

The issue is occurring due to the presence of overflow:scroll.

To resolve this, eliminate overflow:scroll from the .groupName section.

Click here for the revised fiddle.

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

I am interested in implementing a variable to define rows within a <tr> element in an HTML table

I am facing an issue with finding specific rows in a table by using a variable like /tr[i]/ where i represents the row I want to access. When I hardcode the element in my code, it works perfectly: driver.find_element_by_xpath("//tbody[@class='sample& ...

jQuery nested menu for enhanced navigation

Hello everyone, I have successfully implemented a jquery-based multilevel navigation menu. When hovering over each subnav, it appears directly below the clicked list item. However, I am encountering an issue where the background color of the selected paren ...

How can I convert a number to the format of hh:mm using Angular?

Within my form, there is an input field that should only accept numbers. Is it possible to format the input number into a hh:mm format once the user enters it? I prefer not to use input type = time. Do you have any suggestions for achieving this? ...

Stop Wordpress from automatically preloading html5 videos

I have a WordPress page containing numerous videos and I am looking to prevent them from preloading using HTML5. The challenge is that I am inserting the videos through the featured media options, which means I cannot directly add the preload="none" attrib ...

Learn the process of adding values to HTML forms within ExpressJS

I am facing a challenge in injecting Javascript variable values into HTML forms on an Expression JS server. I am unsure about how to solve this issue. All I want to do is insert the values of x, y, and res into the forms with the IDs 'firstvalue&apos ...

"Maintaining Consistency: Ensuring The First Row is Repeated on Every

When trying to save a PDF using jspdf, I encountered an issue with tables in my HTML. The tables do not have headers, but JsPDF is automatically repeating the first row of the table on every page, causing overlap. I don't want headers on every new pag ...

Developing a custom styling class using JavaScript

Looking to create a custom style class within JavaScript tags. The class would look something like this: #file-ok { background-image: url(<?php echo json.get('filename'); ?>); } Essentially, the value returned from the PHP file (json ...

Struggling with implementing the use of XMLHttpRequest to transfer a blob data from MySQL to JavaScript

I have a blob stored in my local WAMP64/MySQL server that I need to retrieve and pass to an HTML file using XMLHttpRequest. I know I should set responseType="blob", but I'm not sure how to transfer the blob from PHP to JavaScript in my HTML file. Any ...

HTML and JavaScript - Facing issues rendering HTML content during the conversion process from Markdown format

In this particular scenario, my goal is to transform the content inside #fileDisplayArea into markdown format. However, I am encountering an issue where the HTML code within the div element is not being rendered. <div id="fileDisplayArea"># Title ...

If you click outside of a Div element, the Div element will close

I am looking for a way to implement a function that will hide a specific div when I click outside of its area. The div is initially set to Position: none and can be made visible using the following function: Div Element: <div id="TopBarBoxInfo1" oncli ...

Getting Started with ThreeJS code results in a console error message

Currently, I am diving into learning Three.js by following their comprehensive getting started guide, which can be found at . I have diligently copied the code provided on the site and ensured that I am using the most up-to-date library. However, when I ex ...

"Enhance your HTML code by inserting clickable hyperlinks within a for loop

I am currently working on a Flask web app that generates an HTML table using static JSON data. The data is correctly displayed in the table, but I am facing an issue with adding hyperlinks to one of the columns that contain links to other websites. Despite ...

Error: Attribute "th:replace" within element type "tr" is invalid because it contains the character '<'

<tr th:replace="textbox1 :: textbox1”></tr> Unfortunately, an error has occurred: org.xml.sax.SAXParseException: The value of attribute "th:replace" associated with an element type "tr" must not contain the '<' character. We n ...

How can I navigate to an anchor using hover?

I'm unsure if I can accomplish this task using just CSS and HTML or if I need to incorporate Javascript because my research did not yield much information on the subject. I have not attempted anything yet as I am uncertain about the approach I should ...

Result box not displaying the expected JQuery UI Autocomplete results

Can someone assist me with Autocomplete? When I search for an RTO code, the result box appears but without a list (refer to Screen : 1). However, when I press the down arrow button on the keyboard, the list starts appearing one by one (as shown in Screen : ...

What is the best way to send information from an MVC controller to JavaScript?

Being new to programming, I am working on 2 projects that function as client-server via Rest API. I am looking to create a column chart using data from a List of ID (participant) and Votes (Total votes) obtained from the server's connection with the d ...

The opacity of a Tailwind color appears differently when applied to the background versus the border

When applying the Tailwind color purple-600/50 to both the background and border of an element, they appear as different colors. It seems like the opacity is not consistent across browsers (tested on Firefox and Safari). View it in action here. <img src ...

How about mixing up your backgrounds with an overlay effect for a unique look?

Hey there, I'm currently working on adding random backgrounds to my website through an overlay, but I've hit a roadblock when it comes to displaying them. Here is the code I'm working with: .css / .php #intro { background: ...

Increasing the size of a background image as you scroll

Is there a way to adjust the background image of a div so that it scales according to the amount the page is scrolled? The current implementation works fine on desktop screens, but on mobile screens, the height of the background image reduces and the image ...

Showing a section of a DIV inside an iframe

I have implemented an HTML object in the following way: <object id="foo" name="foo" type="text/html" data="mypage.aspx"> </object> However, I do not want to display the entire content of mypage.aspx within the HTML object/iframe. In ...