锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
I have noticed myself to use a few different code snippets on a daily basis so I thought some of you might find them useful. So here we go.
The CSS
This is an oldie, but apperantly it is not as obvious as you would think.
Sticky Footer (make footer always be on bottom without absolute positioning)
The HTML
The CSS
As of recently i have had to use this over 50 times… i think this is one of the most important tricks you will learn today.
Cross-Browser Min Height
The CSS
You can replace the min-height and heigth with 12em or another value that works for you.
Box Shadow (CSS3)
The CSS
As you can see since this is a CSS3 property you will need all the three commands to make it cross browser(except for ie of course). The first 2 measurements are for horizontal offset and the vertical offset. The third number is for the blur radius. And the last is the color of the shadow.
Text Shadow (CSS3) with IE hack
The CSS
This technique is great for all modern browsers, the IE fix works but it is not amazing quality.
Cross Browser CSS Opacity
The CSS
Opacity can be used for plenty of elements, it adds a certain new age style we all strive for. Notice that in some browsers transperancy is inherited by all child elements!
The Famous Meyer Reset
The CSS
This is the most useful css reset out there, i use it for almost everything I work on (even the 52framework, coming soon).
Removing the dotted outlines
The CSS
I find myself getting very annoyed with the dotted outline (especially for text-indented elements that are off the page).
Rounded Corners (non ie)
The CSS
Love rounded corners? Don’t want to slave over images and elements to get the effect? This is your solution, and elements still look fine in ie.
Override Inline Styles
The CSS
This comes in handy plenty of times, I personally use it way too much everytime something doesn’t work I test if its just not being applied because of some other style.
ul.demolayout {
list-style-type: none;
float: left;
margin:0px;
padding:0px;
}
ul.demolayout li {
margin: 0 0 0 0;
float: left;
border-bottom:1px solid #515151;
}
.tab{
padding:0 0 2px 0;
height: 160px;
text-align:left;
}
ul.demolayout a {
float: left;
display: block;
padding: 5px 25px;
border-bottom: 0;
color: #515151;
text-decoration: none;
font-size:14px;
font-weight: bold;
}
ul.demolayout a:hover {
background: #eee;
}
ul.demolayout a.active {
background: #515151;
padding-bottom: 5px;
cursor: default;
color:white;
}
.tabs-container {
clear: left;
padding:0px;
}
p.more_details{
padding:2px 2px 2px 2px;
font-size:11px;
}
</style>
</HEAD>
<BODY>
<div id="demo" class="demolayout">
<ul id="demo-nav" class="demolayout">
<li><a class="active" href="#tab1" id="1">媧誨姩璧勮</a></li>
<li><a class="" href="#tab2" id="2">涓氭佸垎甯?lt;/a></li>
<li><a class="" href="#tab3" id="3">鍟嗗鎺ㄨ崘</a></li>
</ul>
<div class="tabs-container">
<div style="display: block;" class="tab" id="tab1">
<p class="more_details">
媧誨姩璧勮鍐呭淇℃伅
</p>
</div>
<div style="display: none; " class="tab" id="tab2">
<p class="more_details">
涓氭佸垎甯冨唴瀹逛俊鎭?br />
</p>
</div>
<div style="display: none; " class="tab" id="tab3">
<p id="comment" class="more_details">
鍟嗗鎺ㄨ崘鍐呭淇℃伅
</p>
</div>
</div>
</div>
</BODY>
</HTML>
b.rtop, b.rbottom{display:block; background: #FFF;}
b.rtop b, b.rbottom b{display:block;height: 1px;
overflow: hidden; background: #FF9E3E;}
b.r1{margin: 0 5px}
b.r2{margin: 0 3px}
b.r3{margin: 0 2px}
b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}
.prod_title{
color:#804000;
text-align:center;
font-size:14px;
font-weight: bold;
padding: 5px 5px;
}
div.details{
padding:2px;
font-size:11px;
text-align:left;
}
.box_center{
width:200px;
height:150px;
padding: 2px;
}
a.more{
font-style:italic;
color:#804000;
float:right;
text-decoration:none;
font-size:11px;
padding:0px 15px 0 0;
}
</style>
</HEAD>
<BODY>
<div id="box">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
<div class="box_center">
<div class="prod_title">鍦嗚嫻嬭瘯</div>
<div class="details">鍐呭淇℃伅</div>
<a href="#" class="more">- 璇︾粏淇℃伅 -</a>
<div class="clear"></div>
</div>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div>
</BODY>
</HTML>
COMSHARP CMS 鍐欓亾錛氬湪綰跨紪杈戝唴瀹圭殑鏃跺欙紝閭d簺鍩轟簬 JavaScript 鐨勭紪杈戝櫒甯簡鎴戜滑澶у繖錛岃繖浜涙墍瑙佸嵆鎵寰楋紙WYSIWYG錛夌紪杈戝櫒錛岀粰鎴戜滑鎻愪緵浜嗙被浼?Office 鐨勬搷浣滀綋楠屻傚浠婏紝浠諱綍緗戠珯鍐呭綆$悊緋葷粺錛圕MS錛夊拰鍗氬緋葷粺閮介渶瑕佷竴涓繖鏍風殑緙栬緫鍣ㄣ傛湰鏂囩簿閫変簡10涓熀浜?JavaScript 鐨勭紪杈戝櫒錛屽畠浠湁鐨勬槸鍩轟簬 jQuery 妗嗘灦錛屾湁鐐瑰垯涓嶆槸銆?/p>
鍔熻兘涓嶆槸寰堝錛屼絾寰堣交閲忥紝寰堢伒媧匯傛墦鍖呭悗鍙湁6.5K澶у皬銆?/p>
闈炲父鍩烘湰鐨勭紪杈戝櫒錛岀畝鍗曚負鏈傛墦鍖呭悗鍙湁7K銆?/p>
綆鍗曞埌涓嶈兘鍐嶇畝鍗曪紝寰堝鏄撹嚜宸變慨鏀廣?/p>
璺ㄦ祻瑙堝櫒錛屽紑婧愶紝鍩轟簬 jQuery銆傚彲浠ュ緢瀹規槗鍚屽悇縐?CMS錛岃鍧涳紝鐣欒█鏈紝鍗氬絳夌郴緇熼泦鎴愩?/p>
鍩轟簬 iframe 瀵硅薄銆?/p>
<!-- ################## NON jQUery ################### -->
鏈緇忓吀鐨勫熀浜?JavaScript 鐨勭紪杈戝櫒錛孋OMSHARP CMS 榛樿鐨勭紪杈戝櫒灝辨槸榪欎釜銆?/p>
鍔熻兘闈炲父寮哄ぇ銆?/p>
鍩轟簬 Yahoo YUI錛岀畝鍗曪紝浣嗗緢鍙潬銆?/p>
鑷敱鐨勫熀浜?nbsp; BSD 璁稿彲緙栬緫鍣紝鍔熻兘瀹屽杽錛屽緢閫傚悎鍚屽悇縐嶇郴緇熼泦鎴愩?/p>
鏈枃鍘熸枃鏉ユ簮錛?a >http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors
package com.founder.web.ext;
import Java.util.Date;
import Java.util.HashMap;
import Java.util.Map;
import org.jmesa.core.filter.DateFilterMatcher;
import org.jmesa.core.filter.FilterMatcher;
import org.jmesa.core.filter.FilterMatcherMap;
import org.jmesa.core.filter.MatcherKey;
public class DateFilterMatcherMap implements FilterMatcherMap {
public Map<MatcherKey, FilterMatcher> getFilterMatchers() {
Map<MatcherKey, FilterMatcher> filterMatcherMap = new HashMap<MatcherKey, FilterMatcher>();
filterMatcherMap.put(new MatcherKey(Date.class, "born"), new DateFilterMatcher("MM/dd/yyyy"));
return filterMatcherMap;
}
}
鐜板湪闇瑕佷慨鏀?span class="pln">tableFacade鏍囩涓?/p>
<jmesa:tableFacade
id="tag"
filterMatcherMap="com.founder.web.ext.DateFilterMatcherMap"
<br>
<br>
textarea瀹藉害鍥哄畾錛岃嚜鍔ㄥ楂?lt;br>
<textarea type="text" style="width:260;overflow-y:visible;"></textarea>
<BODY>
<p>Move your mouser over the red square.</p>
<div id="div1" style="background-color:red; height:50px; width:50px" onmouseover="showTip(event);" onmouseout="hideTip(event);"><div>
<div id="divTip1" style="background-color:yellow;position:absolute;visibility:hidden;padding:5px">
<span style="font-weight:bold">Custom Tooltip</span><br/>
</div>
</BODY>
</HTML>
<BODY>
<div style ="background-color:blue; color:white; font-weight:bold; padding:10px; cursor:pointer" onclick="toggle('divContent1');">Click Here</div>
<div style="border:3px solid blue; height:100px;padding:10px" id="divContent1">
This is some content to show and hide.
</div>
<div style ="background-color:blue; color:white; font-weight:bold; padding:10px; cursor:pointer" onclick="toggle('divContent2');">Click Here</div>
<div style="border:3px solid blue; height:100px;padding:10px" id="divContent2">
This is some content to show and hide.
</div>
</BODY>
</HTML>
鍏蜂綋浣跨敤鍔炴硶錛?br /> 鍒?a target="_blank" rel="nofollow">snap緗戠珯鍙互鐢寵鍒頒竴孌電被浼間互涓嬪艦寮忕殑浠g爜錛?br />
<script defer id="snap_preview_anywhere" type="text/javascript" src="http://spa.snap.com/snap_preview_anywhere.js?ap=1&key=739080a127808f9856fa43a8c91c4d21&sb=1&domain=dimlau.com"></script>
涓嬮潰璇磋浠g爜鐨勪慨鏀癸細
1銆佷嬌鐢ㄩ粯璁ょ殑浠g爜錛岄紶鏍囩Щ鍔ㄥ埌閾炬帴涓婃椂鏄劇ず鐨勬晥鏋滄槸甯︽悳绱㈡鐨勶紝浣嗘槸鍙互閫氳繃淇敼浠g爜鏉ュ幓鎺夋悳绱㈡錛屽厛鐪嬫晥鏋滃姣旓細
淇敼鏂規硶鏄紝灝嗚幏寰椾唬鐮佷腑鐨?strong>sb=1鏀規垚sb=0
2銆侀粯璁や唬鐮佹晥鏋滄槸欏甸潰涓殑鎵鏈夐摼鎺ラ兘鏈夐紶鏍囧垝榪囨椂鏄劇ず緙╃暐鍥炬晥鏋溿?/strong>濡傛灉浣犳兂瀵規煇涓壒瀹氶摼鎺ョ鐢ㄧ緝鐣ュ浘鏁堟灉錛屽彲浠ュ璇ラ摼鎺ュ姞涓婁竴涓垎綾繪潵鏍囪瘑錛?br /> 渚嬪閾炬帴
<a href="xxxx">xxx</a>錛岀鐢ㄧ緝鐣ュ浘鐨勬柟娉曟槸鍐欐垚
<a href="xxxx" class="snap_nopreview">xxx</a>
閫氬父錛屼竴涓〉闈㈤噷澶ч儴鍒嗛摼鎺ユ垜浠兘涓嶆兂鍔犲叆緙╃暐鍥劇殑錛屾墍浠ヤ笂榪板姙娉曟湁鐐圭儲鐞愪簡銆?br /> 鍏跺疄鍙互閫氳繃淇敼浠g爜涓殑ap=1涓?strong>ap=0鏉ヤ嬌欏甸潰鐨勬墍鏈夐摼鎺ュ湪榛樿鎯呭喌涓嬩笉鏄劇ず緙╃暐鍥撅紝榪欐椂鍙湁閾炬帴鍐欐垚浠ヤ笅鏍煎紡鐨勬儏鍐典笅鎵嶄細鏈夌緝鐣ュ浘鏄劇ず錛?br />
<a class="snap_preview" href="XXX">XXX</a>
瀵逛簬涓婅堪鍚勭鎯呭喌錛屽鏋滈摼鎺ユ湰韜凡緇忔湁浜嗘煇涓猚lass鍒嗙被錛屾瘮濡傚凡緇忓垎綾諱負class="123",鍙互鐢?strong>絀烘牸鏉ュ垎闅旓紝騫惰祴浜堝涓猚lass鍒嗙被錛屾瘮濡?br /> class="123 snap_nopreview"鎴栬卌lass="123 snap_preview"
浠ヤ笂涓烘湰浜虹殑涓鐐瑰皬灝忓績寰楋紝甯屾湜瀵瑰悇浣嶇湅瀹樻湁鐐瑰府鍔┿?br /> --------------------------------------------------------------------------------------------------------
瀵逛簬鎴戜嬌鐢ㄧ殑MT錛屽彲浠ュ妯$増涓殑璇勮鑰呯綉绔欓摼鎺ュ艦寮忓姞鍏ヤ竴涓猚lass="snap_preview"鏉ュ疄鐜板璇勮鑰呯綉绔欑晫闈㈢殑鍒濇棰勮錛屾垜瑙夊緱鏄釜涓嶉敊鐨勫皬宸ュ叿銆?br />
褰撶劧鍏朵粬紼嬪簭錛屼篃鍙互鍋氱浉搴旂殑淇敼瀹炵幇璇ユ晥鏋溿傛垜灝變笉鍐嶅璇翠簡銆?/p>
body {background-color:red;}
絎簩涓槸鑳屾櫙涓虹豢鑹茬殑CSS鏂囦歡錛?/span>green.css錛?/span>CSS涓殑鍐呭涓猴細
body {background-color:green;}
絎笁涓槸鑳屾櫙涓洪粍鑹茬殑CSS鏂囦歡錛?/span>yellow.css錛?/span>CSS涓殑鍐呭涓猴細
body {background-color:yellow;}
鐒跺悗鍦?/span>xthml鏂囦歡涓姞鍏ヨ繖涓変釜CSS鐨勯摼鎺?/span>
<link rel="alternate stylesheet" href="red.css" type="text/css" title="red" media="screen, projection"/>
<link rel="stylesheet" href="green.css" type="text/css" title="green" media="screen, projection"/>
<link rel="alternate stylesheet" href="yellow.css" type="text/css" title="yellow" media="screen, projection"/>
榪欎笁涓腑闄や簡title涓嶄竴鏍峰榪樻湁涓涓湴鏂規湁鎵涓嶅悓錛岄偅灝辨槸REL銆傜涓涓笌絎笁涓兘鏄?/span>alternate stylesheet鍙湁絎簩涓槸stylesheet銆傝繖絎簩涓氨鏄綋鐒舵牱寮忋?/span>
鍦ㄩ摼鎺ヤ笅闈㈠啀瀵煎叆涓涓?/span>JS鏂囦歡錛岀敤鏉ユ帶鍒惰繖涓牱寮忓垏鎹?/span>
function setActiveStyleSheet(title) {
var i, a, main;
if (title) {
for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
a.disabled = true;
if(a.getAttribute('title') == title) a.disabled = false;
}
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title');
}
return null;
}
鍦ㄥ悎閫傜殑鍦版柟鍔犲叆涓変釜鍒囨崲鎸夐挳
<a href="javascript :void()" onclick="setActiveStyleSheet('red'); return false;" title="綰㈣壊鏍峰紡"></a>
<a href="javascript :void()" onclick="setActiveStyleSheet('green'); return false;" title="緇胯壊鏍峰紡"></a>
<a href="javascript :void()" onclick="setActiveStyleSheet('yellow'); return false;" title="榛勮壊鏍峰紡"></a>
<a href="javascript :void()" onclick="setActiveStyleSheet('none'); return false;" title="娌℃湁鏍峰紡"></a>
濂戒簡鍙戝竷璇曡瘯鐐歸偅涓変釜鍒囨崲閾炬帴錛佹槸涓嶆槸宸茬粡鍒囨崲浜嗘牱寮忥紵
琛ラ仐錛氬甫鏈夎蹇嗗姛鑳界殑JS鏂囨。
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName
("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style")
!= -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title)
a.disabled = false;
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName
("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style")
!= -1 && a.getAttribute("title") && !a.disabled)
return a.getAttribute("title");
}
return null;
}
function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName
("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+";
path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return
c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie :
getPreferredStyleSheet();
setActiveStyleSheet(title);
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie :
getPreferredStyleSheet();
setActiveStyleSheet(title);
disc | Default. Solid circles. |
circle | Outlined circles. |
square | Solid squares. |
decimal | 1, 2, 3, 4, and so on. |
lower-roman | i, ii, iii, iv, and so on. |
upper-roman | I, II, III, IV, and so on. |
lower-alpha | a, b, c, d, and so on. |
upper-alpha | A, B, C, D, and so on. |
none | No marker is shown |