CSS: Even when text is concealed using text-overflow:ellipses, it remains in existence

I am dealing with a ul element that contains li's of varying lengths but with a fixed width. Each li also has some icons within it.

<ul>
    <li><span class="icon"></span>Long Text with text-overflow:ellipsis</li>
    <li><span class="icon"></span>Short text</li>
    <li><span class="icon"></span>Long Text with text-overflow:ellipsis</li>
</ul>

Within the li elements, I have set the text-overflow property to text-overflow:ellipsis;. However, the clipped text that would overflow is blocking cursor interaction with elements behind it (specifically, .icon)

This is my CSS:

.icon {
    height:18px;
    width:18px;
    float:right;
    cursor:pointer;
    background:url(icons.png);
    background-position:-72px -72px;
}
.icon:hover {
    background-position:-90px -72px;
}
li {
    text-overflow:ellipsis;
    height:20px;
    overflow:hidden;
    white-space:nowrap;
    list-style-type:none;
    width:150px;
}

Please refer to my jsfiddle for a better explanation:

http://jsfiddle.net/eXXTG/

The obscured text hidden by text-overflow:ellipses is preventing the DOM from registering cursor interactions on elements behind the text.

Do you have any suggestions for resolving this issue?

Thank you!

Answer №1

One way to enhance is by including

position: relative 

within the .icon style

Answer №2

To make the icon display properly, simply include the block property in the icon class:

.icon {
    height:18px;
    width:18px;
    background:url(http://www.example.com/icons.png);
    float:right;
    /*this is necessary for proper alignment*/
    cursor:pointer;
    background-position:-72px -72px;
    display: block;
}

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

HTML - Image is only partially visible

While attempting to set up this theme for my blog, I encountered a minor issue - the avatars in the comment section are not displaying correctly, as they appear to be cut off along with the container. Despite numerous attempts to edit the code, I have be ...

What's the best way to target an element that is outside a certain parent container, but based on the parent's class?

Looking to target specific divs with a data-role of content that are not nested within a data-role="page" div with the class "modal". Advanced CSS selectors are not my forte. <div> <div data-role="page"> <div data-role="content" ...

Center-align text so it is perfectly centered over an image

Looking for help with aligning text in social media images? Currently, the text is positioned at the bottom of each image. Check out this example: http://jsfiddle.net/uT4Ey/ CSS: .img { background-color: red; height: 3em; width: 3em; display: inl ...

Material UI Paper component does not extend to full viewport height

My React component includes a Material UI <Paper> component that acts as a background. This <Paper> is nested inside a <ThemeProvider>, which in turn is nested within a <div>, and then further nested inside the <body>. I have ...

The importance of color value is underscored

Is there a way to remove the surrounding color from the value in Visual Studio Code and only display the little square on the left side? [.nav-link-wrapper a { color: #ec0b0b } ] https://i.stack.imgur.com/5uA9k.png ...

Importing fonts using CSS

Currently, I have 4 different fonts that I need to incorporate into a website, and their files are saved within my website folder. Baskerville.ttc BellGothicstd-Black.otf BellGothicstd-Bold.otf JennaSue.ttf I attempted to import the fonts using @Import, ...

Ways to apply the margin-top property to create space between an input field and

I have been experimenting with Vue and I created a simple code snippet. <template> <div> <input /> <span class="span-text">Hi</span> </div> </template> // index.css .span{ margin-top: 3px; } I a ...

Tips for updating the color of an active navbar:

<div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item mx-4"> <a class="nav-l ...

Achieving a full-screen div or video that remains fixed in a specific position on the browser window can be done by following these steps

I am seeking guidance on how to create a video or div that remains fixed in a specific position while adjusting its size to always match the browser window. You can see an example of what I am aiming for here. The website mentioned above contains a video ...

I have noticed that the Javascript code is being loaded prior to the completion of my HTML/CSS page for some unknown

I am completely new to the world of web development. I'm encountering an issue where my JavaScript code (specifically alerts) is loading before my HTML/CSS page has fully loaded. I've been using sample alerts to test this out, and ideally, they s ...

How can CSS3 be used to target the initial or final visible element in a selection?

Looking to style form fieldsets with margins, while removing the margin-top for the first non-hidden fieldset and margin-bottom for the last non-hidden fieldset (any fieldset can be dynamically set as hidden by a script). I attempted the CSS below without ...

Utilizing the CSS Top and Left attributes along with Jquery animations

There are two divisions on a page, namely Left_Div and Right_Div. The images in the Right_Div are positioned using CSS properties such as Top and Left. The Left_Div acts as a left panel, and upon clicking a button, both Left_Div and Right_Div animate to sl ...

Unable to display specific data in Drop Down using AngularJS

I've encountered an issue with my dropdown menu not displaying data when I select the appropriate option. There are two choices available. CSHTML <ui-select ng-model="ctrl.requestType" theme="selectize" title="Choose type of requisition" style="m ...

The appearance of a soft keyboard on mobile devices causes the resizing of the web

View before keyboard appears View after keyboard pops up I want the layout to remain unchanged when the keyboard shows, allowing users to scroll freely. Below is the code snippet: <html> <header> <title>Test Page</title> <meta ...

Adjust the spacing between the button and input field in a fixed position form

I have created a sticky form that is fixed at the bottom of the page. How can I reduce the gaps in this sticky form? between the input field and the button between the button and the frame between the input field and the frame Here is the link t ...

Using clip-path in SVG works perfectly on images, but unfortunately it does not work on div

I came across an interesting example on MDN about using a clip-path SVG on an image. However, it seems that the same clip-path does not work properly when applied to a div. Can anyone shed some light on: The reason why this code is not achieving the inte ...

The appearance of Bootstrap 4 post cards on my website appear to be distinct

I came across a Bootstrap 4 card snippet that I wanted to integrate into my WordPress plugin. However, after integrating it, the display seemed different from the original form. My goal is to showcase posts in a 3-column layout. I noticed that some post ...

Creating a scrollable table with CSS: A step-by-step guide

My table has too many columns causing it to exceed the width of the screen. I would like to make it scrollable horizontally for a neater and more organized appearance. I believe CSS with the overflow hidden property can achieve this, but I am unsure where ...

Include "+5" in cases where additional elements cannot be accommodated

I am working on a project where I have a div called ItemsContainer that dynamically renders an array of items (Item) depending on the screen size. While mapping through the array, I want to check if there is enough space to display the current item. If no ...

The problem arises when the body/html element is narrower than the browser window

I encountered a strange issue while working on a website for a client/design studio. Despite setting the body and html elements to a width of 100%, I noticed that when I resize the browser, a scrollbar appears forcing me to scroll right. Upon scrolling, I ...