Archive for the "技术-HTML&JS" Category

25
6

Motools 研究报告

Author: Johnny Walker

之前做JS接触到的大多是dojo,jquery,prototype,WZ之流,多少存在一些问题。

直到接触JOOMLA,发现里面有些很酷的效果,而且性能也很好才发现都是幕后功臣motools也是个不错的东东。

MOTOOLS

特点介绍:

  • style非常干净,采用后期事件注入的方式。页面上全是class 
  • 对变形效果支持好,这是MOTOOLS的核心功能
  • 调用方便,写的代码非常少,而且分离很好
  • 完全的oop风格

核心feature:

Accordion:文字卷帘,可以在一页显示多页信息,点击标签卷帘收缩展开

customEvent:1.对mouse wheel的支持,2. 可以定义全局的特殊方法,比如enter事件的处理,然后做控件-方法绑定即可,使用继承方式来获得系统事件,例如:keyenter 就是原来的系统事件

Element.Events.keyenter = {
 base: ‘keyup’,
 condition: function(e){
  // We can basically put any logic here.
  // In this example we return true, when the pressed key is the
  // Enter-Button so the keyenter event gets fired.
  return e.key==’enter’;
 }
};

绑定过程也非常简单
 $(’myElement’).addEvent(’keyenter’, function(e){
  // We can do everything here: submitting a form, sending an AJAX-Request and so on
  // because it only fires when the user presses the Enter-Button
  e.stop();

  // But instead we only change the text of an element.
  $(’myDivElement’).set(’text’, ‘You pressed enter’).highlight();
 });

SORT/Dynamic Sortables排序

支持drag and drop 的排序。而且item可以runtime 生成

EFFECT:渐变变形/MOTOOLS 精髓

还记得JOOMLA酷酷的黑色弹出框吗?其实那在MOTOOLS不过是一DIV变型,
MOTOOLS支持的变形有morph,erase,tween,start
包括变长度,变颜色,变透明度,位置移动,或者甚至CSS的改变,可贵的是motools支持的全部都是渐变的动画效果

Slide:

变形的衍生功能,可以收缩控件做出某种slide效果,

Mouseenter和Mouse leave:加强的mouseenter和mouse leave,javascript的mouse enter 和leave 一直不太好用,要么不调,要么反复掉,现在MOTOOLS把它增强了。

Json/Ajax:仍然是很干净很简单的style来支持ajax

更多精彩请看源码!我已经把motools的sample一一下载并打包上传了,点击这里下载

 

17
6

http://sixrevisions.com/tools/faster_web_page/

就是一些测试web page loading performance的东东.

web page的提速一般有以下几个方向:

1. 减少http connection打开的次数, 比如把所有js并成一个, 把所有css并成一个. 使用一个大的PNG把所有图标都放上面, 然后用css里不同的position去控制显示哪个图标, 这些都是尽量减少http connection连接次数

2. 压缩, gzip支持

3. 优化和压缩css和js, 减少空格和换行, 以减少文件大小

4. 减少一个page里包含很多domain下的resource. 避免多余的DNS lookup

5. 还有很多小玩意, 比如让page早点load出来, 在body和head中间flush一下…

17
6

CSS的N多跨平台的Tips, 值得一看, 值得记录一下

You might be interested to check our other related post for some inspiration:

IE Bug Fixes

1- Bug Fix: IE Double Margin Float Bug- It’s an Internet Explorer-exclusive bug wherein an element that is floated – and given a margin in the same direction as the float – ends up with twice the specified margin size. The fix is extremely simple. All you have to do is apply a display: inline rule to your floated element. So you simply go from something like this:

#content {
    float: left;
    width: 500px;
    padding: 10px 15px;
    margin-left: 20px; }

To something like this:

#content {
    float: left;
    width: 500px;
    padding: 10px 15px;
    margin-left: 20px;
    display:inline;
}

CSS Tips


2-Overcoming the Box Model Hack- If you want to specify a width to any div, do NOT specify padding or margins. Just create an inner div with no width set and specify its padding and margins instead. So instead of doing this:

#main-div{
width: 150px;
border: 5px;
padding: 20px;
}

Do something like this:

#main-div{
width: 150px;
}
#main-div div{
border: 5px;
padding: 20px;
}

3-Min-height attribute ignored in IE- “min-height” attribute works well in Firefox but IE ignores it. IE’s height act as FF’s min-height. Note: in IE 7 problem was fixed.

/* for understanding browsers */
.container {
width:20em;
padding:0.5em;
border:1px solid #000;
min-height:8em;
height:auto;
}
/* for Internet Explorer */
/*\*/
* html .container {
height: 8em;
}
/**/

4- Min-Width for IE -A fix for the lack of min-width in Internet Explorer.


Centering a Block Element

5-Centering Block Element- There are multiple techniques for centering a block element; and the choice for the technique depends on whether you have the size set in percentages or in more absolute values.

Centering an entire page’s contents:

body{
text-align: center;
}
#container
{
text-align: left;
width: 960px;
margin: 0 auto;
}

6-Vertical Align with CSS- If you want to know how you can achieve vertical-align functionality the right way, simply specify the line-height for your text the same height as that of the container’s.

#wrapper {
	width:530px;
	height:25px;
	background:url(container.gif) no-repeat left top;
	padding:0px 10px;
}
#wrapper p {
	line-height:25px;
}

Column Issues

7- Top reasons your CSS columns are messed up- An easy-to understand article on how to fix common CSS Column issues with helpful diagrams and code snippets.

CSS Tips


8- The Expanding Box Bug-When you try to create a two-column float layout, IE will create a “float drop”, and it’s caused by having over-sized content in a fixed-width floated div that must fit into a particular spot in the layout. Several possible workarounds are detailed in this post.

CSS Tips


CSS Positioning

9- Understanding CSS Positioning part 1- An interesting series of articles that doesn’t only cover positioning, but also properties that define layout such as display and float, and a preview of the new CSS3 layout modules. The first part will introduce the positioning and display property. Part1, Part2, Part3 gives you a deep understanding of the possibilities you have in positioning.

CSS Tips


10- What is the difference between relative and absolute positioning?- Whether to use relative or absolute positioning can be extremely frustrating to people just getting started with CSS. The answer to this question will add a bit of clarity to this confusion.

#redSquare
{
position: relative;
bottom: 40px;
right: 40px;
}

To get this:

CSS Tips


11-HangTab- Create a Sticky Tag from the Edge of the Browser Window (Even with Centered Content). Check out Panic’s website for their software Coda.

#hang_tab {
position: absolute;
top: 7px;
left: 0px;
width: 157px;
height: 93px;
}

CSS Tips


CSS Float Concept

12- CSS Float Theory: Things You Should Know- SmashingMagazine browsed through dozens of related articles and selected the most important things you should keep in mind developing css-based layouts with floats.

<div> <!-- float container -->
<div style="float:left; width:30%;"><p>Some content</p></div>
<p>Text not inside the float</p>
<div style="clear:both;"></div>
</div>

13- Floatutorial: Simple tutorials on CSS Floats- Floatutorial takes you through the basics of floating elements such as images, drop caps, next and back buttons, image galleries, inline lists and multi-column layouts.

CSS Tips


14- Clear Your Floats - The Right Way- Float clearing can be one of the most frustrating aspects of CSS development, one of the best ways is to use the EasyClearing on your site.

/* EasyClearing http://www.positioniseverything.net/easyclearing.html */
#container:after
{
	content: ".";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}

#container
{display: inline-block;}

/* Hides from IE-mac \*/
* html #container
{height: 1%;}

#container
{display: block;}
/* End hide from IE-mac */

CSS Tips


Easier Rounded Corner Solutions

15- Mike asks the CSS Guy for recommendations on rounded corners- “Simplest way is to use a giant gif, then I’ll markup my box”

<div class="roundBox">
  <p>beautifully-encapsulated paragraph</p>
  <div class="boxBottom"></div>
</div>

“And give it the background”

.roundBox {
  background:transparent url(roundBox.gif) no-repeat top left;
  width:340px;
  padding:20px;
}
.roundBox .boxBottom {
  background:white url(roundBox.gif) no-repeat bottom left;
  font-size:1px;
  line-height:1px;
  height:14px;
  margin:0 -20px -20px -20px;
}

Also Askthecssguy explains the technique used in Google Analytics, which works by leaving a 1px notch in every corner to get the rounded corner effect which is a new way of creating rounded corners without using static images. You can see an example here.

CSS Tips


16-3 Simple Steps in Coding a Rounded Corners Layout- Alen Grakalic’s approach to coding a fixed width, rounded corners layout in 3 simple steps. He also created a demo here.

CSS Tips


CSS Form Issues

17- Tips For Creating Great Web Forms- Cris Coyer shares with us some tips for floating labels, :focus Pseudo Class, using hints and more. He also created the Nice & Simple Contact Form, which he first posted about here.

label {
	float: left;
	text-align: right;
	margin-right: 15px;
	width: 100px;
}

CSS Tips


18- Clean and pure CSS FORM design- For CSS lovers, this tutorial illustrates a proposal about how to design a pure CSS form without using html tables. You can grab the code here.

CSS Tips


19-Autopopulating text input fields with JavaScript- Sometimes we need to explain to users what they are supposed to enter into text input fields. One common workaround when no label can be displayed is to put some placeholder text in the text field and let that act as the label. This tutorial introduces a nice solution, with JavaScript enabled, the label element is hidden and the value of the input element’s title attribute is copied to the value attribute. If JavaScript is disabled, the label is displayed above the text input, which is left empty. A simple demo, where you can see this in action is here.

CSS Tips


Worth checking CSS Tricks

20- Cross browser Horizontal Rule with Background Image- You’d like to create a cross-browser horizontal rule that utilizes a custom image as the content separator.

div.hr {
background: #fff url(myhrimg.gif) no-repeat scroll center;
height: 10px
}
div.hr hr {
display: none
}

Your tag should look like this:

<div class="hr"><hr /></div>

http://www.noupe.com/css/using-css-to-fix-anything-20-common-bugs-and-fixes.html
16
5

CSS范例

Author: 乌鱼

CSS范例, 需要写出来有层次

css_example

28
3

在apache中可能会使用URL重写,此时通常使用.htaccess来实现,要注意的是在.htaccess文件中有可能要加入RewriteBase /pug/admin/new/, 就是说apache在rewrite URL时有一个base URL,如果不设置这个的话可能出现文件找不到的错误