Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take percentage widths/heights into account #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Take percentage widths/heights into account #188

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 19, 2014

When using percentages as widths or heights, the existing code returns an Integer value through parseInt (100% becomes 100), resulting in an incorrect video aspect ratio. I've added a check for the '%' character in the conditional statements, so that when percentage widths and height are used, the actual height or width of the object on the screen is measured by jQuery (using width() and height() functions).

When using percentages as widths or heights, the existing code returns an Integer value through parseInt (100% becomes 100), resulting in an incorrect video aspect ratio. I've added a check for the '%' character in the conditional statements, so that when percentage widths and height are used, the actual height or width of the object on the screen is measured by jQuery (using width() and height() functions).
@kenhowardpdx
Copy link
Collaborator

The reason we use parseInt is because a percentage is not a valid value for the width property.

@ghost
Copy link
Author

ghost commented Aug 25, 2014

Percentage widths and heights were allowed for Iframes in HTML 4.01 (http://www.w3.org/TR/html401/present/frames.html#h-16.5) and I've come across a few projects where they are still in use (even if they shouldn't be). I realize Iframes should not accept percentages, but all major browsers accept and render those width and height definitions.

It all boils down to a matter of philosophy, I guess?

@kenhowardpdx
Copy link
Collaborator

A percent unit on height does nothing (It has no value to base itself upon). Width of a percentage unit does indeed expand to a percentage of it's container, although that is considered an old practice and you should instead set width and height with the style attribute.

Look at Issue #116 for more info on why this is the way it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants