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 6714121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:27:32+00:00 2026-05-26T08:27:32+00:00

http://jsfiddle.net/nicktheandroid/tVHYg/ When hovering .wrapper , it’s child element .contents should animate from 0px to

  • 0

http://jsfiddle.net/nicktheandroid/tVHYg/

When hovering .wrapper, it’s child element .contents should animate from 0px to it’s natural width. Then when the mouse is removed from .wrapper, it should animate back down to 0px. The .wrapper element should only be as wide as it needs to be (allowing .contents to grow), so .wrapper should grow in width and shrink in width as .contents does. There should be no set width for .contents. I’m using CSS3, but it could be accomplished in jQuery, that would be fine.

The problem:
See the JSfiddle

  1. .wrapper is not only as wide as it needs to be.
  2. when .contents grows, when it’s almost at it’s full width, it jumps down to the next line
  3. When hovering off of .wrapper, .contents vanishes, when it should animate down to 0px
.wrapper {
    display: inline-block;

    height: 20px;
    width: auto;
  
    padding:10px;
  
    background:#DDD;
}

.contents {
    display:inline-block;
  
    width:0%;
  
    white-space:nowrap;
    overflow:hidden;
  
    background:#c3c;
}

.wrapper:hover .contents {
    -webkit-transition: width 1s ease-in-out;
    -moz-transition: width 1s ease-in-out;
    -o-transition: width 1s ease-in-out;
    transition: width 1s ease-in-out;

    width:100%;
}
<div class="wrapper">
    <span>+</span>
    <div class="contents">These are the contents of this div</div>
</div>
  • 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-05-26T08:27:32+00:00Added an answer on May 26, 2026 at 8:27 am

    I think I’ve got it.

    .wrapper {
        background:#DDD;
        display:inline-block;
        padding: 10px;
        height: 20px;
        width:auto;
    }
    
    .label {
        display: inline-block;
        width: 1em;
    }
    
    .contents, .contents .inner {
        display:inline-block;
    }
    
    .contents {
        white-space:nowrap;
        margin-left: -1em;
        padding-left: 1em;
    }
    
    .contents .inner {
        background:#c3c;
        width:0%;
        overflow:hidden;
        -webkit-transition: width 1s ease-in-out;
        -moz-transition: width 1s ease-in-out;
        -o-transition: width 1s ease-in-out;
        transition: width 1s ease-in-out;
    }
    
    
    
    .wrapper:hover .contents .inner {
       
        width:100%;
    }
    <div class="wrapper">
        <span class="label">+</span>
        <div class="contents">
            <div class="inner">
                These are the contents of this div
            </div>
        </div>
    </div>

    Animating to 100% causes it to wrap because the box is bigger than the available width (100% minus the + and the whitespace following it).

    Instead, you can animate an inner element, whose 100% is the total width of .contents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/nicktheandroid/yWKMD/ Look at the example, when you click the element, it rotates around from
http://jsfiddle.net/nicktheandroid/k93ZK/2/ This should be really simple, I just don't understand why it's not working.
http://jsfiddle.net/fQv97/ HTML <div class=table-cell> My text, should be align middle </div> CSS .table-cell {
http://jsfiddle.net/nicktheandroid/SsfpG/ I don't understand why these inline elements are causing the paragraph to stop
http://jsfiddle.net/nicktheandroid/B7Rhe/5/ I'm trying to make the next slide fade in over the current slide,
http://jsfiddle.net/nicktheandroid/TWKJb/5/ Once you grab the handler and start to drag it, the handlers left
http://jsfiddle.net/nicktheandroid/6BAfH/1/ The list-elements are sorted accordingly by the number in their span. Why is
http://jsfiddle.net/nicktheandroid/QhL2M/ (type bye into the input box) Purpose of the script: Each li contains
http://jsfiddle.net/nicktheandroid/7raYa/9/ My script allows me to scroll the page like a PDF, allowing you
http://jsfiddle.net/nicktheandroid/3AraQ/ When a P is hovered over, #both is appended to that paragraph and

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.