-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Added a new function for use in fluid/responsive layouts #481
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
Conversation
…imensions in pixels and returns their ratio as a percentage. Updated unit tests to include the function.
Can you explain what this function is intended to do? |
Hey Matthew, When creating fluid or responsive layouts you work with percentages instead My initial experiments showed I could do the following: @container : 900px; .blog_post { and I would get the results I wanted. However, I wasn't sure this was the I considered writing the function as a plugin, but that wouldn't be Unfortunately, naming things is difficult. I just threw out 'fluid' because Thanks for making this awesome tool. Thanks for contacting me so quickly. On Wed, Nov 23, 2011 at 1:47 PM, matthewdl <
Tim Reynolds |
… to parse variables in media query statements. Add unit test
Hmm.. This wasn't meant to go onto this pull request. It was meant as a new pull request. Sorry. Trying to figure out what I should do here... |
@razialx you should create a new branch for each pull request. once you open a pull request anything you commit to that branch is included in that existing pull request. this allows you to iterate on your open pull request without needing to open a new one every time you need to tweak the code. |
Thanks. Took a little bit to get it right but I managed. Pretty new to Git. On Thu, Dec 1, 2011 at 4:41 PM, Ben Hockey <
Tim Reynolds |
I think there's actually an undocumented percentage function in LESS, but I'm not sure if it handles this or not. I found it the other day whilst browsing the source code, as one does when one is in need for some R&R. |
I think I was on crack, because I don't see it. Where did I see that? |
Hmm, not sure. I actually thought I saw something like what I wanted in The function here is just a nice shortcut. On Thu, Dec 29, 2011 at 2:33 PM, matthewdl <
Tim Reynolds |
Though, without it, the workaround is based on undocumented functionality,
It seems it works by chance that the result is in percentages vs by design. Thanks On Thu, Dec 29, 2011 at 3:28 PM, Tim Reynolds [email protected] wrote:
Tim Reynolds |
Yep, I've had to use the same percentage hack. Usually you can "cast" a unit that way, so it's not a huge big deal, but I could see the convenience of having a dedicated function. |
There is indeed a |
Added a new function: fluid(target, container)
Converts two tree.Dimensions with type 'px' (or null) to their ration expressed as a percentage ('%')
Examples:
fluid(10px,200px) -> 5%
fluid(48,900) -> 5.3333333333%
Also, updated the unit tests appropriately.