The names in the lists appear with a visible scrollbar, making them easily

I'm having some issues with this dropdown menu. http://jsfiddle.net/vnr0rbuu/2/

The problem arises when using a different mouse or a PC, as the scrollbar appears and my list items don't apply the inline-block style correctly.

Any suggestions on how to fix this?

This is my HTML:

    <ul class="app-dropdown">
        <li class="app">
            <ul class="app-list">
                <li class="app-name">
                    <p>Android Application With a really long name</p>
                </li>
                <li class="app-icon">
                    <img src=""/>
                </li>
            </ul>
        </li>
        <li class="app">
            <ul class="app-list">
                <li class="app-name">
                    <p>Frustrating situation</p>
                </li>
                <li class="app-icon">
                    <img src=""/>
                </li>
            </ul>
        </li>
    </ul>

And here is my CSS:


    .app-dropdown {
        display: block;
        position: absolute;
        min-width: 160px;
        max-width: 300px;
        max-height: 350px;
        margin: 15px;
    }

        .app {
            display: block;
            padding: 15px 25px;
            border-bottom: 1px solid #F4F4F4;    
            vertical-align: middle;
            text-align: right;

        }

            .app-list {
                display: inline-block;
            }
            .app-name {
                padding-right: 5px;
                display: inline-block;
                vertical-align: middle;
            }
                .app-name p { /* Truncate long name */
                    max-width: 150px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
            .app-icon {
                display: inline-block;
            }
                .app-icon img {
                    border-radius: 3px;
                    display: inline-block;
                    vertical-align: middle;
                }

Answer №1

Quick overview: HTML is a markup language that categorizes text on the internet. It's crucial to use it properly to ensure clarity and structure. Nesting lists within a list for a UI design that only requires a single list can be confusing. The following example demonstrates more appropriate markup.

HTML

<ul class="app-dropdown">
  <li>
      <label>Android Application With a real long name</label>
      <img src="http://cl.ly/image/3I2I2a0i3Z2g/overview-3.png"/>
  </li>
  ... (additional list items)
  <li>
      <label>Very long long long app name</label>
      <img src="http://cl.ly/image/3I2I2a0i3Z2g/overview-3.png"/>
  </li>
</ul>

Below is the CSS code for styling the above HTML. Make sure to refer to resources like MDN and caniuse.com for detailed documentation and compatibility checks with different platforms.

CSS

* { margin:0; padding:0 }

body {
  font-family: "Open Sans", sans-serif;
}

... (continuation of CSS styling)

For practicing and testing your code, utilize platforms like Jsbin, CodePen, or Dabblet which offer live updates as you type.

Demo: http://jsbin.com/luviya/2/edit

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

"Border-radius becomes less prominent on pointer interaction in Chrome and Safari due to WebKit's behavior

Having an issue with a list inside a div. The problem arises when there is a div containing a list, which limits the visibility of items for users. If the limit is exceeded, a scroll bar appears inside the div to allow users to see more items. Additionally ...

How can I open a new window, redirect the current one, and bring focus to the new window using JavaScript?

Trying to troubleshoot a problem I'm having with the following setup: - Using SAP Portal, I am launching an HTML page containing this code. - The goal is for the HTML page to open a new window. - Once the new window opens, the original HTML page ...

Is it possible for a search box selection toggle to reveal a hidden information box underneath it containing all the compiled data?

Improve the user experience on my website by implementing a search feature for US states and Canadian territories. When visitors type in their selection, I want them to be able to click on an icon that will reveal relevant information about that choice. T ...

What is causing justifyContent: space-between not to function properly?

I want to display Text1Text2Text3Text4Text5Text6Text7 at the top with text alignment using justifyContent: 'space-between'. However, when I tried to do so, all texts ended up at the top. <div style={{display: 'flex-item', flex: 1, ...

Changing the icon dynamically when a user unfollows through an AJAX request

I have created a follow icon (button) that allows signed-in users to click on it and add the game to their list using AJAX. However, I need help with switching the button icon and class. I'm not very familiar with JavaScript or AJAX. This is the cur ...

When the user clicks on the element, the onclick function captures the input data from

I'm currently learning JavaScript and attempting to redirect to a different page based on user input. /MenuDemo1/src/home.jsp After filling in the two text boxes above and clicking the button, I manage to retrieve the username and password. However, ...

Maintain mouse attention through CSS

Currently, I am facing an issue with my login screen involving the mouseenter and mouseleave events. I have a gif image that disappears when the mouse hovers over it and reappears when the cursor moves to a different part of the page to allow users to ente ...

Switching between jQuery toggleclass and a button action to a Checkbox action

Hey there! I am currently working with code in Wordpress using the DIVI theme builder. I am still new to JS and jQuery, so bear with me. I recently found a cool Night Mode feature that activates when a button is clicked. I stumbled upon a custom toggle swi ...

Unable to use addEventListener on media queries exceeding 768px

When testing the site on Firefox 49 and Chrome 63, I encountered the same issue. Clicking on each card worked fine on iPhone4, Galaxy 5, and iPhone 8 using Chrome. However, after switching orientations from 640px to 320px portrait view, the top card would ...

Verification of radio selections

I have successfully implemented validation for the radio button. Now, I would like to add an alert box that asks "Are you sure you want to pick 'x'?" before proceeding with the code. If the user clicks cancel, they should return to the webpage. B ...

Creating a Simple HTML Table Using PHP Arrays

I attempted to create a simple PHP array table, but the output of my code did not meet my expectations. <?php $names = array ( 'First Name' => array('Alfre', 'Beka', 'Charlie'), ...

How can I organize a dictionary based on a specified key order in Jinja2?

Suppose I need to showcase the following data: • b is foo • a is bar • c is baz ...however, my dataset is structured like this (or any other sequence due to JSON's flexibility): { "a": "bar", "b": "foo", "c": "baz" } How can I utilize Jinja2 ...

The animation for the CSS gradient background is failing to animate

After finding a similar code snippet used for backgrounds, I made some modifications to suit my needs. However, when attempting to implement it or any animation, nothing seems to be working. Even simple animations are not functioning as expected. While I a ...

Creating a visually appealing background image using WordPress and PHP

Currently struggling with adjusting the width of an image that's set as a background in Wordpress. The text is perfectly centered, but the background image remains full size and I want it to match the container size... You can view the image at the t ...

An issue occurred in the evaluation of tidy when attempting to access the object 'titles' in the mask

Whenever I attempt to run this code, an error pops up. My goal is to extract data from multiple pages. However, when executing the script below, I encounter the following error message: Error in eval_tidy (xs [[j]], mask): object 'titles' not f ...

Implementing a button row and content alignment next to an image using Bootstrap or CSS

Ensure that the product detail page features a row with labels and buttons, positioned to the right of the image within Bootstrap columns. I have utilized Bootstrap 3 for this page layout. However, upon implementation, I encountered an issue whereby the b ...

Show an SVG overlay when hovering over an image

Is there a way to create a hexagon shape around an image when it is hovered over using CSS only, even if the image itself has a circular border-radius of 50%? ...

Display or Conceal form based on radio button selection of affirmative or negative

I'm experimenting with using jQuery to display more or less of a form depending on the user's selection. If the user chooses 'Yes,' then additional form fields will be shown. I intend to implement this feature for various top-level ques ...

"Present information in a dual-column format with the use of HTML code

I am having trouble with my HTML5 code because I am attempting to display content in two columns. Here is a snippet of my HTML code: .column1 { float: left; width: 70%; } <div class="cd-admin-upper-container container-fluid"> <div class=" ...

Steps to insert additional characters surrounding the innerhtml of an h2 element

After extensive searching, I still can't seem to figure this out. It's possible I'm overlooking something very obvious, and for that, I apologize. My current challenge involves adding two specific characters to multiple h2 elements. While I ...