www.webdeveloper.com
Results 1 to 6 of 6

Thread: Fixed size div

  1. #1
    Join Date
    Oct 2013
    Posts
    4

    Fixed size div

    I am trying to create a div element with fixed size in html. My problem is, the above div receives input text from javascript. The size of text is unknown, so every time that the transmitted text is big, automatically the size of the div is change. How is it possible to display only the first words of the text that fit in the predefined size of the div???

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Us CSS to set the DIV size and also font and texts size defaults.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Oct 2013
    Posts
    4
    The problem is that the font size and text size constantly changes. An effect that i want to keep. I define default size, for my div element. Nevertheless, every time that the text is big, it change the div size. I want to display only the text that fits in div, whichever the size of text and font are.

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    maybe overflow:hidden will help?
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  5. #5
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    div#setsize{max-height:xxpx; max-width:xxpx; overflow:scroll;}

    where setsize is the id of the div you are attacking with this CSS, the xxpx is the size in pixels, eg..

    div#setsize{max-height:400px; max-width:300px; overflow:scroll;}

    so as soon as your content gets larger than the 400px height limitation, your overflow should scroll.

    You would need to work on the scroll bars, the only option I see that you have is to scale the DIV content so it fits and is still maintaining some flavor of your original content.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  6. #6
    Join Date
    Oct 2013
    Posts
    4
    Yea i got it, thanks guys!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles