Skip to main content

Posts

Showing posts with the label css

Moving Items Along Bezier Curves with CSS Animation (Part 2: Time Warp)

This is a follow-up of my earlier article.  I realized that there is another way of achieving the same effect. This article has lots of nice examples and explanations, the basic idea is to make very simple @keyframe rules, usually just a linear movement, then use timing function to distort the time, such that the motion path becomes the desired curve. I'd like to call it the "time warp" hack. Demo See the Pen Interactive cubic Bezier curve + CSS animation by Lu Wang ( @coolwanglu ) on CodePen . How does it work? Recall that a cubic Bezier curve is defined by this formula : \[B(t) = (1-t)^3P_0+3(1-t)^2tP_1+3(1-t)t^2P_2+t^3P_3,\ 0 \le t \le 1.\] In the 2D case, \(B(t)\) has two coordinates, \(x(t)\) and \(y(t)\). Define \(x_i\) to the be x coordinate of \(P_i\), then we have: \[x(t) = (1-t)^3x_0+3(1-t)^2tx_1+3(1-t)t^2x_2+t^3x_3,\ 0 \le t \le 1.\] So, for our animated element, we want to make sure that the x coordiante (i.e. the "left" CSS property) is \(...

Moving Items Along Bezier Curves with CSS Animation (Part 1: Constructions)

TLDR: This article is NOT about cubic-bezier(), and it is not about layered CSS animations (for X and Y axes respectively). It is about carefully crafted combined animation, that moves an element along any quadratic/cubic Bezier curve. UPDATE: Here's the link to part 2 . Following my previous post , I continued investigating competing CSS animations, which are two or more CSS animations affecting the same property. I observed that two animations may "compete". In the following example, the box has two simple linear animations, move1 and move2. It turns out the box actually moves along a curved path: See the Pen CSS Bezier Path by Lu Wang ( @coolwanglu ) on CodePen . So clearly it must be the combined effects from both animations. Note that in move2, the `from` keyframe was not specified. It'd look like this if it is specified: See the Pen For Blog 2022-08-02 by Lu Wang ( @coolwanglu ) on CodePen . In this case, it seems only the second animation take...

Studying CSS Animation State and Multiple (Competing) Animations

[2022-08-04 Update] Most of my observations seems confirmed in the CSS animation spec . I stumped upon this youtube video . Then after some discussion with colleages,  I was really into CSS-only projects. Of course I'd start with a rotating cube: See the Pen CSS 3d Animation Test by Lu Wang ( @coolwanglu ) on CodePen . Then I built this CSS-only first person (rail) shooter: See the Pen CSS-Only Wolfenstein by Lu Wang ( @coolwanglu ) on CodePen . It was lots of fun. Especially I learned about the checkbox hack .  However there were two problems that took me long to solve. 1. Move from in the middle of an animation The desired effect is: An element is moving from point A to point B. If something is clicked, the element should move from its current state (somewhere between A and B, in the middle of the animation/transition) to another point C. This is for the last hit of the boss, the boss is fastly moving. I'd like the boss to slowly move to the center if being...

Notes 20130505

'tc' and 'netem' allow you to simulate some network environments http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution For example, I can delay every packet for 1s, such that in some case I can cheat in games. Google Chrome complains about "profile cannot be opened correctly": remove the 'web data' folder in the config dir http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html To remove PDF password with gs http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10 would ignore the `word-spacing` CSS rule if the width for the space char is 0, in a TTF font. Is it a bug of IE?

杂记 20130505

使用tc + netem可以模拟一些网络环境 http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution 比如我可以让每个包都延迟1秒,某些情况下玩游戏还可以作弊 Google Chrome说Profile无法正确打开: 把配置目录里的'Web Data'目录干掉 http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html 用gs去除PDF的密码: http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10下如果TTF字体的空格宽度是0,就会无视word-spacing的css规则,不知道是不是IE的bug。

Webkit 下中文字体问题的解决 | Solution to the problem of unexpected Chinese fonts in webkit

也许是仅局限于webkitgtk 之前尝试epiphany的时候就发现了这个问题,但是由于epiphany对我来说只是一个备用浏览器,所以没管它。 今天给empathy搞adium主题时这个问题再次蹦了出来,我决定干掉它。 https://bugs.launchpad.net/ubuntu/+source/webkit/+bug/502610 这里有些讨论,里面有个链接指向了改fontconfig的办法,但是我想我这里并不是这个问题,因为我在~/.fonts.conf里已经之定好了我希望的中文字体(主要是serif, sans-serif, monosapce这几个列表),我还是觉得这个是webkit的问题。 empathy有个选项可以开启webkit debug模式:/apps/empathy/conversation/enable_webkit_developer_tools 我用它查看元素,发现字体总是sans...目前解决方法是手工改css,找到.msg的定义,加入 font-family: "font name 1", "font name 2"; 另外就是epiphany,虽然它不能给各个语言指定字体,但是好歹支持用户css,于是加入如下内容: @charset "UTF-8"; // 如果字体名有中文 * { font-family: "font name 1", "font name 2" ! important; } 这样问题基本可以解决 Or maybe it's only a bug for webkitgtk, I'm not sure. Days before I encountered this bug when I was trying epiphany, but I didn't pay much attention on it since I use it only as a backup one. However today the bug came out and started to trouble me again when I was applying an adium theme for empa...

在Blogger首页显示文章摘要二解

在首页显示摘要是个不错的主意,可惜Blogger默认不支持. 网上倒是有一些解决方案,不过我都不大喜欢,因为需要修改文章模板,每次创建文章时还要指定哪里是摘要,哪里是全文,不爽. 我希望摘要的生成是自动的,可且应当便于修改. 网上好像有个这样的脚本,不过我网络不好,下不来... 经过两天的研究,我完成了两种方案. 方案一,根据行数定摘要. 修改模板, 加入CSS /* added by WangLu for summary display */ div.wl_summary{ height: 10em; max-height: 10em; overflow-y: hidden; } 另外在post-body的定义中,把<p><data:post.body/></p> 改为 <!-- added by WangLu --> <!-- display summary on the main page --> <b:if cond='data:blog.pageType == "item"'> <p><data:post.body/></p> <b:else/> <p> <div class='wl_summary'> <data:post.body/> </div> </p> ... <br/> <br/> <a expr:href='data:post.url'>Read more...</a> </b:if> 就行了. 此法优点是改动少,速度快,代码简单,且发文时无需添加额外信息 不过需要说明几点: 1. 在Firefox里指定height或max-height都可以达到效果,但是IE不支持max-height 2. 关于height的值可能需要根据实际字体进行修改, 设置不当容易出现半个字的情况. 3. 即使文章很短,也会出现'...'和Read more字样,逻辑上有点小问题. ...

[转]53 CSS-Techniques You Couldn’t Live Without

很漂亮 //原文   53 CSS -Techniques You Couldn’t Live Without 53个 CSS -不可或缺的技巧 QUOTE: CSS is important. And it is being used more and more often. Cascading Style Sheets offer many advantages you don’t have in table-layouts - and first of all a strict separation between layout, or design of the page, and the information, presented on the page. Thus the design of pages can be easily changed, just replacing a css-file with another one. Isn’t it great? Well, actualy, it is. CSS 是重要的,它正在越来越广泛的被运用。层叠样式表拥有很多表格布局所没有的优势,首先从布局或者页面的设计与出现在页面中的信息中作严格的分离,从而让页面的设计能够很容易被改变,仅用一个 CSS 文件更换另一个。难道它不够强大吗?恩,是的,其实它很强大。 QUOTE: Over the last few years web-developers have written many articles about CSS and developed many useful techniques, which can save you a lot of time - of course, if you are able to find them in time. Below you’ll find a list of techniques we , as web-architects, really couldn’t live without. They are essential and they indeed make our life easier. Let’...