dimensions

Total width of element (including padding and border) in jQuery

白昼怎懂夜的黑 提交于 2019-11-26 23:32:24
As in the subject, how can one get the total width of an element, including its border and padding, using jQuery? I've got the jQuery dimensions plugin, and running .width() on my 760px-wide, 10px padding DIV returns 760. Perhaps I'm doing something wrong, but if my element manifests itself as 780 pixels wide and Firebug tells me that there's 10px padding on it, but calling .width() only gives 760, I'd be hard pressed to see how. Thanks for any suggestions. Andreas Grech [Update] The original answer was written prior to jQuery 1.3, and the functions that existed at the time where not adequate

Check image dimensions (height and width) before uploading image using PHP

倖福魔咒の 提交于 2019-11-26 23:06:36
问题 How can I check for height and width before uploading image, using PHP. Must I upload the image first and use "getimagesize()"? Or can I check this before uploading it using PHP? <?php foreach ($_FILES["files"]["error"] as $key => $error) { if( $error == UPLOAD_ERR_OK && $_FILES["files"]["size"][$key] < 500000 && $_FILES["files"]["type"][$key] == "image/gif" || $_FILES["files"]["type"][$key] == "image/png" || $_FILES["files"]["type"][$key] == "image/jpeg" || $_FILES["files"]["type"][$key] ==

VideoView to match parent height and keep aspect ratio

一世执手 提交于 2019-11-26 22:14:01
I have a VideoView which is set up like this: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/player" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <VideoView android:id="@+id/video" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerInParent="true" android:layout_centerVertical="true" /> <ProgressBar android:id="@+id/loader" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout

How to get scrollTop of an iframe

蹲街弑〆低调 提交于 2019-11-26 20:12:05
问题 jQuery's scrollTop returns null when window is an iframe. Has anyone been able to figure out how to get scrollTop of an iframe? more info: my script is running in the iframe itself, the parent window is on another domain, so I can't access the ID of the iframe or anything like that 回答1: You can set scrollTop by using this setup: $("html,body").scrollTop(25); So you could try getting it like this: $("html,body").scrollTop(); Because different browsers set the scrollTop on different elements

Get image dimensions with Javascript before image has fully loaded

耗尽温柔 提交于 2019-11-26 20:03:51
I've read about various kinds of ways getting image dimensions once an image has fully loaded, but would it be possible to get the dimensions of any image once it just started to load? I haven't found much about this by searching (which makes me believe it's not possible), but the fact that a browser (in my case Firefox) shows the dimensions of any image I open up in a new tab right in the title after it just started loading the image gives me hope that there actually is a way and I just missed the right keywords to find it. You are right that one can get image dimensions before it's fully

How to return the number of dimensions of a (Variant) variable passed to it in VBA

两盒软妹~` 提交于 2019-11-26 18:55:11
Does anyone know how to return the number of dimensions of a (Variant) variable passed to it in VBA? Jacob Function getDimension(var As Variant) As Long On Error GoTo Err Dim i As Long Dim tmp As Long i = 0 Do While True i = i + 1 tmp = UBound(var, i) Loop Err: getDimension = i - 1 End Function That's the only way I could come up with. Not pretty…. Looking at MSDN, they basically did the same. To return the number of dimensions without swallowing errors: #If VBA7 Then Private Type Pointer: Value As LongPtr: End Type Private Declare PtrSafe Sub RtlMoveMemory Lib "kernel32" (ByRef dest As Any,

Numpy array dimensions

落爺英雄遲暮 提交于 2019-11-26 17:53:52
问题 I'm currently trying to learn Numpy and Python. Given the following array: import numpy as np a = np.array([[1,2],[1,2]]) Is there a function that returns the dimensions of a (e.g.a is a 2 by 2 array)? size() returns 4 and that doesn't help very much. 回答1: It is .shape: ndarray. shape Tuple of array dimensions. Thus: >>> a.shape (2, 2) 回答2: First: By convention, in Python world, the shortcut for numpy is np , so: In [1]: import numpy as np In [2]: a = np.array([[1,2],[3,4]]) Second: In Numpy,

How to get the resolution of a monitor in Pygame?

百般思念 提交于 2019-11-26 16:36:08
问题 I'm just wondering if it is possible for me to get the resolution of a monitor in Pygame and then use these dimensions to create a window so that launching the program detects the monitor resolution and then automatically fits the window to the screen in fullscreen. I am currently using pygame.display.set_mode((AN_INTEGER, AN_INTEGER)) to create the window. I am aware that you can get video info including the monitor resolution using pygame.display.Info() but how can I extract these values

What is the difference between getWidth/Height() and getMeasuredWidth/Height() in Android SDK?

别来无恙 提交于 2019-11-26 15:19:47
问题 The Android Documentation says that there is two sizes for a view, the measured dimensions and the drawing dimensions . The measured dimension is the one computed in the measure pass (the onMeasure method), while the drawing dimensions are the actual size on screen. Particularly, the documentation says that: These values may, but do not have to, be different from the measured width and height. So, my question is: what could make the drawing dimension be different of the measured dimension? If

CUDA determining threads per block, blocks per grid

為{幸葍}努か 提交于 2019-11-26 15:13:37
问题 I'm new to the CUDA paradigm. My question is in determining the number of threads per block, and blocks per grid. Does a bit of art and trial play into this? What I've found is that many examples have seemingly arbitrary number chosen for these things. I'm considering a problem where I would be able to pass matrices - of any size - to a method for multiplication. So that, each element of C (as in C = A * B) would be calculated by a single thread. How would you determine the threads/block,