dcsimg
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,601
    Us CSS to set the DIV size and also font and texts size defaults.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  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,687
    maybe overflow:hidden will help?

  5. #5
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,601
    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.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  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