為什么input標(biāo)簽選擇器不能居中?
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
<style>
#div1{width:300px;height:300px;background:red;margin:auto}
input {
? ?margin:auto;
? ?
}
</style>
</head>
<body>
<input type="button" value="換色" />
<div id="div1">
</div>
</body>
</html>
2016-12-09
input是行內(nèi)元素,要先設(shè)置為塊級(jí)元素再設(shè)置居中 ? 多加一個(gè)style屬性:使用display來設(shè)置為塊級(jí)元素,之后才能生效,下面有代碼:
<input style="display:block" type="button" value="換色" ?/>
2016-12-09
你要是向更加深入了解,可以看看這篇博客:http://www.jb51.net/css/80872.html
2016-12-09
加個(gè)標(biāo)簽,在另一個(gè)標(biāo)簽設(shè)置居中
2016-12-09
input是行內(nèi)元素,要先設(shè)置為塊級(jí)元素再設(shè)置居中
2016-12-09
因?yàn)閕nput標(biāo)簽不具有這個(gè)屬性