jQuery Animation – Smooth Size Transition

Try this jQuery plugin: // Animates the dimensional changes resulting from altering element contents // Usage examples: // $(“#myElement”).showHtml(“new HTML contents”); // $(“div”).showHtml(“new HTML contents”, 400); // $(“.className”).showHtml(“new HTML contents”, 400, // function() {/* on completion */}); (function($) { $.fn.showHtml = function(html, speed, callback) { return this.each(function() { // The element to be modified var … Read more

Autoresize textbox control vertically

The current selected answer does NOT handle lines with no spaces such as “jjjjjjjjjjjjjjjjjjjj”x1000 (think about what would happen if someone pasted a URL) This code solves that problem: private void txtBody_TextChanged(object sender, EventArgs e) { // amount of padding to add const int padding = 3; // get number of lines (first line is … Read more

Automatically resize images with browser size using CSS

To make the images flexible, simply add max-width:100% and height:auto. Image max-width:100% and height:auto works in IE7, but not in IE8 (yes, another weird IE bug). To fix this, you need to add width:auto\9 for IE8. source: http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries for example : img { max-width: 100%; height: auto; width: auto\9; /* ie8 */ } and then … Read more

Scale image to fit a bounding box

Thanks to CSS3 there is a solution ! The solution is to put the image as background-image and then set the background-size to contain. HTML <div class=”bounding-box”> </div> CSS .bounding-box { background-image: url(…); background-repeat: no-repeat; background-size: contain; } Test it here: http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=contain Full compatibility with latest browsers: http://caniuse.com/background-img-opts To align the div in the center, … Read more

Android: How to Programmatically set the size of a Layout

Java This should work: // Gets linearlayout LinearLayout layout = findViewById(R.id.numberPadLayout); // Gets the layout params that will allow you to resize the layout LayoutParams params = layout.getLayoutParams(); // Changes the height and width to the specified *pixels* params.height = 100; params.width = 100; layout.setLayoutParams(params); If you want to convert dip to pixels, use this: … Read more

Numpy Resize/Rescale Image

Yeah, you can install opencv (this is a library used for image processing, and computer vision), and use the cv2.resize function. And for instance use: import cv2 import numpy as np img = cv2.imread(‘your_image.jpg’) res = cv2.resize(img, dsize=(54, 140), interpolation=cv2.INTER_CUBIC) Here img is thus a numpy array containing the original image, whereas res is a … Read more

Can I style the resize grabber of textarea?

WebKit provides the pseudo-element ::-webkit-resizer for the resize control it automatically adds to the bottom right of textarea elements. It can be hidden by applying display: none or -webkit-appearance: none: ::-webkit-resizer { display: none; } <textarea></textarea> This displays as follows in Chrome 26 on OS X: Note: Adding display: none to ::-webkit-resizer doesn’t actually prevent … Read more