Ways to have the "li" element displayed on a separate line

let selector = document.querySelector('.activate')

selector.addEventListener('mouseover', function(){
    document.querySelector('#hidden-li').classList.remove("hidden")
})

selector.addEventListener('mouseleave', function(){
    document.querySelector('#hidden-li').classList.add("hidden")
})
.menu-list{
    width: 40%;
    margin: 0 auto;
    border: 1px solid black

}

.menu-list ul{
    display: flex;
    flex-shrink: 0;
    padding: 0;
    justify-content: space-evenly;
    list-style-type: none;
    flex-wrap: wrap;
    margin-bottom: 0;

}
.menu-list ul li{

    text-align: center;
    flex: 1;
    border: 1px solid purple;
    width: 20%;
}
.menu-list ul li a{
    font-size: 1.2rem;
    text-decoration: none;
    color: black;
}

.hidden {
    display: none;
}
<div class = "menu-list">
        <ul>
            <li><a>TEMP1</a></li>
            <li><a>TEMP2</a></li>
            <li class = "activate"><a>TEMP3</a></li>
            <li><a>TEMP4</a></li>
            <li><a>TEMP5</a></li>
            <li id = "hidden-li" class = "hidden"><a>TEMP6</a></li>
        </ul>
    </div>

I have created a menu list with a total of 5 li items displayed in the same line. When I hover over Temp3, it triggers the visibility of Temp6 to be shown. However, despite trying various CSS settings like setting flex-shrink to zero, enabling flex-wrap and adjusting the width size, I can't seem to get Temp6 to display on a new line. The flex container keeps shrinking the other li items. Any suggestions on how else I can approach this issue?

Answer №1

From what I gather, the goal is to have the first 5 elements appear on the same line while the 6th element is displayed on a new line... To accomplish this, you should change the "display" property to "inline" instead of "flex" for the first 5 elements, and set the "display" property to "block" for the last element. This adjustment will result in the desired layout...

Here's a simplified CSS example:

ul li {
    display:inline;
    color:red;
}
ul li:last-child {
    display:block;
    color:green;
}

Ultimately, the last element will either be styled as "display:none" or "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

Can a small white pop-up be triggered by clicking a button?

While exploring the website , I noticed that clicking on Availability Zones opens a small window with text on the right side of the page. Is it possible to achieve a similar feature on a leaflet map without using JavaScript? This functionality would be tri ...

Deactivating a form field depending on a selected radio button in Angular 2

If I have two radio buttons, with a click function called localClick for the first button to give value 1 and the second button to give value 2. <div class="ui-g-12"><p-radioButton name="group1" value="Local" (click)=localClick(1) label="Local"&g ...

Is jQuery failing to respond after being transferred from HTML to PHP?

The debug message from the Venkman debugger reads as follows: $("#aboutbox") is null [Break On This Error] $("#aboutbox").hide(); I'm at a loss on how to resolve this issue! It was functioning perfectly in HTML: But after transitioning it to PH ...

Automatically updating database with Ajax post submission

I have customized the code found at this link (http://www.w3schools.com/PHP/php_ajax_database.asp) to update and display my database when an input box is filled out and a button is clicked to submit. Below is the modified code: <form method="post" acti ...

Trigger the callback function once the datatables DOM element has finished loading entirely

Hello there! I have a question regarding datatables. Is there any callback function available that is triggered after the datatables DOM element has finished loading? I am aware of the callbacks fnInitComplete, but they do not serve my purpose. Specificall ...

Chrome Table not behaving as expected when expanding div

I'm encountering an issue on my website where everything works perfectly in Firefox, IE, and Safari, but there is a glitch in Chrome. You can see the problem here: http://tinyurl.com/chxg2tb In Chrome, the table at the bottom extends beyond the cont ...

Using Python Selenium to extract data - a step-by-step guide

Here is the link you are looking for: I have successfully accessed this website using Selenium-Webdriver in Python. My next task is to extract the information about the battery type. https://i.sstatic.net/mSd6Y.jpg ...

Issue with overflow in TailwindCSS design

I'm working on implementing a unique layout using Tailwind CSS for a dashboard. The height of the initial view should match the screen size and remain within those limits at all times. Initially, the blue section of the dashboard will be empty (but ...

How does Angular5 perform with Bootstrap4?

Currently working on an Angular5 application and considering integrating bootstrap into it. I imported Bootstrap4, which includes dependencies on JQuery and Popper.js. Another option I came across is utilizing CSS grid for more versatility compared to boo ...

Tips for creating a div that is consistently 80% of the page height and perfectly square

Sorry if this question seems a bit confusing, but I just can't seem to find the right words to explain it! What I'm trying to achieve is having a div element always be 80% of the height of the page, while also being perfectly square in shape. In ...

Learn the step-by-step process of cropping and zooming an image using the react-image-crop

I am looking to implement zooming and cropping functionality for an image using react-image-crop instead of react-easy-crop. Currently, the cropping does not take into account the zoom level set by ReactCrop's scale property. I want to be able to zo ...

If the div is devoid of content, then remove the class

<div class="slider">content goes here</div> <div id="slider-2" class="active inactive">also some content here</div> <script type="text/javascript"> function checkEmpty( element ){ return !$.trim(element.html()) ...

Compilation of CSS by Webpack resulting in peculiar class identifiers

Currently, I am using webpack for developing a React app with a NodeJS backend. I've encountered an issue with styling the app as webpack seems to be interfering with my CSS, causing changes in class names. For example, in my base.css file, I have d ...

Adjusting the alignment of Bootstrap navbar items upon clicking the toggle button

When I click the toggle button on a small screen, my navbar items appear below the search bar instead of aligning with the home and about elements. Below is an image depicting this issue: https://i.stack.imgur.com/4rabW.png Below is the HTML code structu ...

A few of the input fields I filled out are not getting sent to the PHP script

Currently, I am working on a school project that involves creating a website similar to IMDB. My task is to include comments in our database, but I am facing an issue where two fields (fid and spoiler) are not getting posted to the PHP script handling the ...

Is it possible to use just one <map> tag for multiple images in jQuery or JavaScript?

I have multiple images on my website <img usemap="#slideMap_branches" src="branches.png" width="890" height="270" alt="Slide 4"> <img usemap="#slideMap_order" src="order.png" width="890" height="270" alt="Slide 2"> <img usemap="#slideMap_c ...

Troubleshoot mobile overflow-x problem when expanding div beyond container boundaries

Recently, I experimented with a method to extend the background-color of my div outside its container. Everything was working fine except for the fact that applying overflow-x to the body on mobile browsers didn't completely disable horizontal scrolli ...

Prevent IonContent from scrolling to the bottom or top when using Ionic framework

In my Ionic app, I have a long text page with 2 buttons that trigger the actions scrollToBottom and scrollToTop. Due to the length of the page, I have set the scroll duration to be 30 seconds. I am facing two issues here: How can I stop the scrolling ...

Footer division misbehaving

My goal is to add a footer to my website that includes a text field, but for some reason I'm encountering an issue with two of my divs not cooperating. You can observe this problem in this JSFiddle. Here is the CSS code for the footer: .footer { b ...