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

  • Home
  • SEARCH
  • 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 8221755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:02:32+00:00 2026-06-07T14:02:32+00:00

I have a div with a paragraph or so of text inside it. I’d

  • 0

I have a div with a paragraph or so of text inside it. I’d like it to show the first few words normally, but expand to show the full text on hover. Ideally, I’d like to do it with only CSS and without data duplication.

This is what I’ve tried:

    <style>
    #data {
    border: solid 2px blue;
    width: 100px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    }

    #data:hover{
    overflow: visible; 
    white-space: normal; 

    }
    </style>

    <div>1: ONE</div>
    <div id="data" style="border: 1px solid #0ff; ">
    2: oianset osietnoasiedj oino aosietnoin oasiento oaseitnoind oisentoasintoon         oisentoiansetoino oiasentoin oi asetin doinae oidnoajosi doinalketn oiwdnota onioiante oaidno </div>
    <div>3: THREE</div>

(available online at http://jsfiddle.net/SEgun/)

I don’t want the divs to move when the text expands, only for div 2 to expand to show the full text covering div 3. Is this possible? I don’t care about supporting obscure browsers.

  • 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-07T14:02:33+00:00Added an answer on June 7, 2026 at 2:02 pm

    The CSS below will cause the div to “cover” everything below it so it doesn’t push any content down.

    position: absolute;
    background-color:#FFF;
    

    The background color is important so you can’t see the stuff below.

    To make sure everything stays in the same place, you can give the next element a top margin of the same value as the line height. The + sign is the adjacent sibling selector.

    div {
        line-height: 20px;
    }
    #data:hover+div {
        margin-top:20px;
    }
    

    DEMO

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

Sidebar

Related Questions

I have HTML code like this: <div id=paragraph> <pre> <p>First Line in the paragraph
I have html like: <fieldset> <div> <ul> <li class=test> This paragraph contains a very
I have div ( #child ) which won't expand to the full height of
I have a div.infotext with one paragraph inside. I animate the height of that
I have a div which contains a paragraph tag which contains text. What I
I have an html paragraph (inside a div) in which I want to display
I have the following: $(content).filter(p:first).text(); where content = <div> <div> <div> <p>adsdas</p> <p>dsa</p> <p>dsa</p>
I have a page so far with: <div id=x1>Text paragraph 1<link here></div> <div id=x2>Text
I have a style for paragraph as <div id=content> Text <ul> <li>One</li> <li>Two</li> </ul>
I have a UTF8 text string that I would like displayed in a div

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.