លំហាត់ CSS-Browser និង Device

លំហាត់ CSS-Browser និង Device
aលំហាត់ទី១ ធ្វើយ៉ាងណាដើម្បីលាក់ កូដ CSS ពី browser ផ្សេង?
aaសរសេរកូដ
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Box Model Hack</title>
<meta http-equiv=”content-type”
content=”text/html; charset=iso-8859-1″ />
<link rel=”stylesheet” type=”text/css” href=”box-model-hack.css”
/>
</head>
<body>
<div id=”mybox”>
<p>This div has a width of 200 pixels, padding of 20 pixels and a
border of 5 pixels.</p>
</div>
</body>
</html>
#mybox {
padding: 20px;
border: 5px solid #000000;
background-color: #00BFFF;
width: 200px;
}
លំហាត់ទី២ ធ្វើយ៉ាងណាដើម្បីបង្កើត print style sheet?
a
សរសេរកូដ
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Print Style Sheet</title>
<meta http-equiv=”content-type”
content=”text/html; charset=iso-8859-1″ />
<link rel=”stylesheet” type=”text/css” href=”main.css”
title=”default” />
<link rel=”stylesheet” type=”text/css” href=”print.css”
media=”print” />
</head>
<body>
<div id=”banner”></div>
<div id=”content”>
<h1>Chinese style stuffed peppers</h1>
<p>These stuffed peppers are lovely as a starter, or as a side
dish for a Chinese meal. They also go down well as part of a
buffet and even children seem to like them.</p>
<h2>Ingredients</h2>

</div>
<div id=”navigation”>
<ul id=”mainnav”>
<li><a href=”#”>Recipes</a></li>
<li><a href=”#”>Contact Us</a></li>
<li><a href=”#”>Articles</a></li>
<li><a href=”#”>Buy Online</a></li>
</ul>
</div>

</body>
</html>
body, html {
margin: 0;
padding: 0;
}
#navigation {
width: 200px;
font: 90% Arial, Helvetica, sans-serif;
position: absolute;
top: 41px;
left: 0;
}
#navigation ul {
list-style: none;
margin: 0;
padding: 0;
border: none;
}
#navigation li {
border-bottom: 1px solid #ED9F9F;
margin: 0;
}
#navigation li a:link, #navigation li a:visited {
display: block;
padding: 5px 5px 5px 0.5em;
border-left: 12px solid #711515;
border-right: 1px solid #711515;
color: #ffffff;
background-color: #b51032;
text-decoration: none;
}
#navigation li a:hover {
color: #ffffff;
background-color: #711515;
}
#content {
margin-left: 260px;
margin-right: 60px;
}
#banner {
height: 40px;
background-color: #711515;
border-bottom: 1px solid #ED9F9F;
text-align: right;
padding-right: 20px;
margin-top: 0;
}
#banner ul {
margin: 0;
padding: 0;
}
#banner li {
display: inline;
}
#banner a:link, #banner a:visited {
font: 80% Arial, Helvetica, sans-serif;
color: #ffffff;
background-color: transparent;
}
#content p, #content li {
font: 80%/1.6em Arial, Helvetica, sans-serif;
}
#content p {
margin-left: 1.5em;
}
#content h1, #content h2 {
font: 140% Georgia, “Times New Roman”, Times, serif;
color: #B51032;
background-color: transparent;
}
#content h2 {
font: 120% Georgia, “Times New Roman”, Times, serif;
padding-bottom: 3px;
border-bottom: 1px dotted #ED9F9F;
}
body, html {
margin: 0;
padding: 0;
}
#navigation {
display: none;
}
#content {
margin-left: 20pt;
margin-right: 30pt;
}
#banner {
display: none;
}
#content p, #content li {
font: 12pt/20pt “Times New Roman”, Times, serif;
}
#content p {
margin-left: 20pt;
}
#content h1, #content h2 {
font: 16pt Georgia, “Times New Roman”, Times, serif;
color: #4b4b4b;
background-color: transparent;
}
#content h2 {
font: 14pt Georgia, “Times New Roman”, Times, serif;
padding-bottom: 2pt;
border-bottom: 1pt dotted #cccccc;
}

លំហាត់ទី៣ អនុញ្ញាត browsers users ដើម្បីជ្រើសរើស style sheet
aសរសេរកូដ
<link rel=”stylesheet” type=”text/css” href=”main.css”
title=”default” />
<link rel=”stylesheet” type=”text/css” href=”print.css”
media=”print” />
<link rel=”alternate stylesheet” type=”text/css”
href=”largetext.css” title=”large text” />
body, html {
margin: 0;
padding: 0;
font-size: 140%;
}
#navigation {
width: 280px;
font: 90% Arial, Helvetica, sans-serif;
position: absolute;
top: 41px;
left: 0;
}
#navigation ul {
list-style: none;
margin: 0;
padding: 0;
border: none;
}
#navigation li {
border-bottom: 1px solid #ED9F9F;
margin: 0;
}
#navigation li a:link, #navigation li a:visited {
display: block;
padding: 5px 5px 5px 0.5em;
border-left: 12px solid #711515;
border-right: 1px solid #711515;
color: #ffffff;
background-color: #b51032;
text-decoration: none;
}
#navigation li a:hover {
color: #ffffff;
background-color: #711515;
}
#content {
margin-left: 320px;
margin-right: 60px;
}
#banner {
height: 40px;
background-color: #711515;
border-bottom: 1px solid #ED9F9F;
text-align: right;
padding-right: 20px;
margin-top: 0;
}
#banner ul {
margin: 0;
padding: 0;
}
#banner li {
display: inline;
}
#banner a:link, #banner a:visited {
font: 80% Arial, Helvetica, sans-serif;
color: #ffffff;
background-color: transparent;
}
#content p, #content li {
font: 80%/1.6em Arial, Helvetica, sans-serif;
}
#content p {
margin-left: 1.5em;
}
#content h1, #content h2 {
font: 140% Georgia, “Times New Roman”, Times, serif;
color: #B51032;
background-color: transparent;
}
#content h2 {
font: 120% Georgia, “Times New Roman”, Times, serif;
padding-bottom: 3px;
border-bottom: 1px dotted #ED9F9F;
}

លំហាត់ទី៤ អនុញ្ញាត browsers users ដើម្បី style sheet ប្តូរបាន
aសរសេរកូដ
<link rel=”stylesheet” type=”text/css” href=”main.css”
title=”default” />
<link rel=”stylesheet” type=”text/css” href=”print.css”
media=”print” />
<link rel=”alternate stylesheet” type=”text/css”
href=”largetext.css” title=”large text” />
<script language=”javascript” type=”text/javascript”
src=”switcher.js”></script>
</head>
<body>
<div id=”banner”>
<ul id=”styleswitch”>
<li><a href=”javascript:;”
onclick=”setActiveStyleSheet(‘default’); return false;”
>Default Style</a></li>
<li><a href=”javascript:;”
onclick=”setActiveStyleSheet(‘large text’); return false;”
>Large Text</a></li>
</ul>
</div>
/*
Paul Sowden’s JavaScript switcher as detailed on:

http://www.alistapart.com/articles/alternate/
*/
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);

Related product you might see:

Share this product :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. ទឹកអំពៅ - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger