css樣式之區(qū)分input是按鈕還是文本框的方法第2/4頁(yè)
更新時(shí)間:2008年09月02日 00:26:12 作者:
對(duì)設(shè)置樣式時(shí)怎么區(qū)分input是按鈕還是文本框問(wèn)題的技術(shù)調(diào)查——把input里面的東西剔出來(lái)
2:用css中的type選擇器
實(shí)現(xiàn)參考代碼:
<!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> diffInput2 </title>
<meta name="Author" content="JustinYoung"/>
<meta name="Keywords" content=""/>
<meta name="Description" content=""/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
input[type="text"]
{
background-color:#FFC;
}
input[type="password"]
{
background-image:url(BG.gif);
}
input[type="submit"]
{
background-color:blue;
color:white;
}
input[type="reset"]
{
background-color:navy;
color:white;
}
input[type="radio"]
{
/*In FF,Some radio style like background-color not been supported*/
margin:10px;
}
input[type="checkbox"]
{
/*In FF,Some checkbox style like background-color not been supported*/
margin:10px;
}
input[type="button"]
{
background-color:lightblue;
}
</style>
</head>
<body>
<dl>
<dt>This is normal textbox:<dd><input type="text" name="">
<dt>This is password textbox:<dd><input type="password" name="">
<dt>This is submit button:<dd><input type="submit">
<dt>This is reset button:<dd><input type="reset">
<dt>This is radio:<dd><input type="radio" name="ground1"> <input type="radio" name="ground1">
<dt>This is checkbox:<dd><input type="checkbox" name="ground2"> <input type="checkbox" name="ground2">
<dt>This is normal button:<dd><input type="button" value="i'm button">
</dl>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title> diffInput2 </title>
<meta name="Author" content="JustinYoung"/>
<meta name="Keywords" content=""/>
<meta name="Description" content=""/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
input[type="text"]
{
background-color:#FFC;
}
input[type="password"]
{
background-image:url(BG.gif);
}
input[type="submit"]
{
background-color:blue;
color:white;
}
input[type="reset"]
{
background-color:navy;
color:white;
}
input[type="radio"]
{
/*In FF,Some radio style like background-color not been supported*/
margin:10px;
}
input[type="checkbox"]
{
/*In FF,Some checkbox style like background-color not been supported*/
margin:10px;
}
input[type="button"]
{
background-color:lightblue;
}
</style>
</head>
<body>
<dl>
<dt>This is normal textbox:<dd><input type="text" name="">
<dt>This is password textbox:<dd><input type="password" name="">
<dt>This is submit button:<dd><input type="submit">
<dt>This is reset button:<dd><input type="reset">
<dt>This is radio:<dd><input type="radio" name="ground1"> <input type="radio" name="ground1">
<dt>This is checkbox:<dd><input type="checkbox" name="ground2"> <input type="checkbox" name="ground2">
<dt>This is normal button:<dd><input type="button" value="i'm button">
</dl>
</body>
</html>
優(yōu)點(diǎn):簡(jiǎn)單,明了,可以分區(qū)出各個(gè)input控件形態(tài)。
缺點(diǎn):type選擇器,IE6之前的對(duì)web標(biāo)準(zhǔn)支持的不太好的瀏覽器不能支持(致命呀 Orz…)
相關(guān)文章
推薦個(gè)不錯(cuò)的表單Input的高級(jí)用法11例
推薦個(gè)不錯(cuò)的表單Input的高級(jí)用法11例...2007-11-11無(wú)js5款純div+css制作的彈出菜單標(biāo)準(zhǔn)
無(wú)js5款純div+css制作的彈出菜單標(biāo)準(zhǔn)...2007-09-09低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案
現(xiàn)在我們可以選擇瀏覽器非常多,所以瀏覽器的環(huán)境也是種類繁多,同一個(gè)瀏覽器也是包含各種不同的版本,不同的版本之間的渲染方法也存在差異,它們支持的 HTML5、CSS3 特性恐怕也不盡相同。這種情況于是造成Web開(kāi)發(fā)者在開(kāi)發(fā)網(wǎng)站時(shí),要面對(duì)數(shù)量龐大的瀏覽器種類2014-03-03