Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:46+00:00 2026-06-15T08:06:46+00:00

JSFiddle – fixed height(s) JSFiddle – problem I have a ul with a fixed

  • 0

JSFiddle – fixed height(s)

JSFiddle – problem

I have a ul with a fixed height. There are two buttons (#up) and (#down) that scroll through the remaining elements when clicked. I would like to remove the fixed height on the ul to allow for varying lengths of copy in each li (currently it allows 3 li’s with a max height of 90px). It works when the height of the ul and max-height of li’s are defined, removing them shows more than the desired (4) amount of li’s.

CSS:

#container ul {
height:400px;
margin: 1em 0 0 0;
padding: 0;
position: relative;
overflow: hidden;
}

#container ul li {
display: none;
min-height: 90px;
font: 0.9em/1.25em Arial, Helvetica, sans-serif;
color: #121c39;
padding: .5em;
border-bottom: 1px dotted #121c39;
background: transparent;
overflow: hidden;
}

#container ul li span {
display: block;
font: bold 1.125em Arial, Helvetica, sans-serif;
}

#container ul li a {
display: block;
color: #121c39;
}

HTML:

   <div class="fourcol">
        <div id="container">
            <a href="#" id="up">Up</a>
            <a href="#" id="down">Down</a>
          <h2>New Arrivals</h2>
          <ul>
            <li><span>Gun 1</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
            <li><span>Gun 2</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
            <li><span>Gun 3</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
            <li><span>Gun 4</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
            <li><span>Gun 5</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
            <li><span>Gun 6</span>Lorem ipsum dolor sit amet,consectetuer adipiscin consectetuer adipi<a href="">Learn More</a></li>
          </ul>
    </div>

and the JS

$('#up').click(function(e){
    var first = $('#container ul li:first');
    first.hide('fast',function(){
        $('#container ul').append(first.show(500));
    });
    e.preventDefault();
});
$('#down').click(function(e){
    var last = $('#container ul li:last');
    last.hide('fast',function(){
    $('#container ul').prepend(last.show(500));
   });
   e.preventDefault();
});

I can get the ul to only show the first 4 (or whatever li’s) with this

$('#container > ul > li:lt(4)').show();

I would like the ul to only show 4 items and scroll through, showing only 4 at a time and keeping them in order. How do I apply the $(‘#container > ul >li:lt(4)’)…. on each click?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:06:47+00:00Added an answer on June 15, 2026 at 8:06 am

    You need to use JS to keep track of how many lis are showing at one time. A CSS solution does not seem possible with varying heights. Something like this:

    //after up/down clicks:
    $("li:gt(3)").hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jsFiddle of the problem here. When I have an image with align=left inside a
JSFiddle Is there any way to make something like the X on that link
JSFiddle: http://jsfiddle.net/QbyUR/ So, I have an empty TD, that I'm trying to remove the
jsFiddle In this example the two quotes both have the same width. What I
http://jsfiddle.net/AndyMP/nUhhf/1/ This is a simplified situation where I have a DIV that animates downwards
jsFiddle I have a DailyMotion video embedded in my page, through an iFrame, within
jsFiddle demonstrating problem: http://jsfiddle.net/calvintennant/nnm64/1/ Sources suggest that adding mesh.flipSided = true will render the
JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user
JsFiddle Link I have two divs overlapping with borders on both. When I set
jsFiddle The left red div will not go all the way down. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.