Size element so it is exactly as tall as it needs to be to not scroll

Size element so it is exactly as tall as it needs to be to not scroll I am working on a tool to allow creating small "notes" that I then turn into Ext.Draggable items. What I would like to do is to have these items be sized no taller than they need to be.

The elements are absolutely positioned: set position: absolute with top and left and height and width values in-line. The problem is that the height values are not really very reliable.

Is it possible to set the size at something very short (say 3px), then increment the height until the scrollbars disappear? How can I tell when that occurs, and can I do it in a way that's reliable across browsers?

Code: http://github.com/artlung/ArtLung-Notes/blob/master/v2/index.js

--------------Solutions-------------

In general, see Ext.util.TextMetrics.getHeight(). Note that you can't use the singleton for height determination.

However, I think that removing explicit height should generally solve your problem. That's unless you need to synchronize something like shadow overlay's size, though.

If an element's style.position is absolute and the style.width is determined, setting its style.height to 'auto' will make a containing box for its content and padding, with no scrollbars.

Category:javascript Time:2010-06-23 Views:0

Related post

  • jQuery Isotope - fluid layout with two different size elements 2011-11-17

    I have a basic layout of photos (for a portfolio) on a page. There are two different size image bricks, the larger one is proportional to the smaller and exactly twice the width and height, and no margin between the blocks or the window. There are on

  • LinearLayout * size element 2012-02-07

    I have a LinearLayout that works great to produce something like: [ fixed image size ] [ fixed image size ] [ text takes up the space that is left ] The XML looks similar to: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android

  • What does the size element in $_FILE represent? 2012-04-03

    I like to ask something that may be simple and stupid, but I can't find out that information in PHP documentation. Does the $_FILE['field_name']['size'] field represent the file size in bytes ? --------------Solutions------------- Yes, http://www.php

  • Syntactic sugar to add variable-size element lists to vector? 2011-08-26

    I have a class that contains a vector: class Foo { typdef std::vector<int> Vec; Vec m_kids; void addKids(Vec::const_iterator begin, Vec::const_iterator end) { m_kids.insert(m_kids.end(), begin, end); } }; Is there any way to allow the following

  • Drag and Select and re-size elements in Canvas WPF c# 2011-10-12

    Now I can draw rectangle in canvas using a mousedown and mousemove events I want to select rectangles and drag them in canvas ( move ) and resize them how ? --------------Solutions------------- http://www.codeproject.com/KB/WPF/WPF_DrawTools.aspx Eve

  • Firefox hides vertical scrollbar if element's height is less than 32px 2009-10-14

    in FF3 (3.0.14) I'm seeing an issue where the vertical scrollbar is hidden on an element if its height is less than 32px. In my (much simplified) example below, the scrollbar doesn't appear on "shouldScroll" - even though its child is larger than it

  • Vertically Center Text in an Input Element 2010-02-08

    I have the following input element (I deliberately omitted attributes which weren't necessary for the example): <input type="text" style="display: block; height: 40px; font-size: 14px; line-height: 40px"> In Chrome and Internet Explorer (probab

  • Vertically and horizonally aligned elements while floating left and right 2012-01-02

    I want to center four links in a div. This is what i did so far: jsfiddle Html: <div id="menu"> <section> <a class="top" href="#">Top</a> <a class="left" href="#">Left</a> <a class="right" href="#">Right</

  • How to find the kth largest element in an unsorted array of length n in O(n)? 2008-10-30

    I believe there's a way to find the kth largest element in an unsorted array of length n in O(n). Or perhaps it's "expected" O(n) or something. How can we do this? --------------Solutions------------- This is called finding the k-th order statistic.

  • How to scroll to an element in jQuery? 2009-02-01

    I have done the following code in JavaScript to put focus on the particular element (branch1 is a element), document.location.href="#branch1"; But as I am also using jQuery in my web app, so I want to do the above code in jQuery. I have tried but don

  • IE7 and 8 smaller font-size issues with SIFR 2009-05-16

    my website http://tweetMP.org.au uses SIFR to render the flash font h2 headings. If you compare the site between Firefox and IE7/8 you'll notice the headings are noticably smaller in IE (7 and 8 only - IE6 looks fine). Adjusting the font-size on my i

  • Java array with more than 4gb elements 2009-05-18

    I have a big file, it's expected to be around 12gb. I want to load it all into memory on a beefy 64bit machine with 16gb ram, but I think Java does not support byte arrays that big: File f = new File(file); long size = f.length(); byte data[] = new b

  • Absolutely positioned div with width 100% is only as wide as the original window size 2009-09-04

    I have an absolutely positioned div that has a width of 100% with a background image tiling horizontally. When the browser is shrunk to the point that the width of the browser is less than the page, the remaining right portion of the div's background

  • jQuery click off element event 2009-09-14

    I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() function callback when hovering off an element. Only I want to do this for click. I tried just setting a cli

  • OpenGL ES - how to keep some object at a fixed size? 2009-11-17

    I'm working on a little game in OpenGL ES. In the background, there is a world/map. The map is just a large texture. Zoom/pinch/pan is used to move around. And I'm using glOrthof (left, right, bottom, top, zNear, zFar) to implement the zoom/pinch. Wh

  • How can I know the ACTUAL maximum number of elements a .net array of a given type can be allocated? 2009-12-03

    I know that all arrays in .net are limited to 2 GB, under this premise, I try not to allocate more that n = ((2^31) - 1) / 8 doubles in an array. Nevertheless, that number of elements still doesn't seem to be valid. Anyone knows how can I determine a

  • Combinations of Multiple Vector's Elements Without Repetition 2009-12-08

    I have n amount of vectors, say 3, and they have n amount of elements (not necessarily the same amount). I need to choose x amount of combinations between them. Like choose 2 from vectors[n]. Example: std::vector<int> v1(3), v2(5), v3(2); There

  • How do I use ViewScripts on Zend_Form File Elements? 2010-01-26

    I am using this ViewScript for my standard form elements: <div class="field" id="field_<?php echo $this->element->getId(); ?>"> <?php if (0 < strlen($this->element->getLabel())) : ?> <?php echo $this->formLabel(

  • How to change size of UIButton 2010-03-27

    I'm trying to resize a UIButton in my iPhone app. I have a UIButton synthesized and when I call the following code, it moves on the screen, but the width & height of the button never change. button.frame.size = CGRectMake(104, 68, 158, 70); For e

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 1.393 (s). 13 q(s)