為什么input標簽選擇器不能居中?
<!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>無標題文檔</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是行內元素,要先設置為塊級元素再設置居中 ? 多加一個style屬性:使用display來設置為塊級元素,之后才能生效,下面有代碼:
<input style="display:block" type="button" value="換色" ?/>
2016-12-09
你要是向更加深入了解,可以看看這篇博客:http://www.jb51.net/css/80872.html
2016-12-09
加個標簽,在另一個標簽設置居中
2016-12-09
input是行內元素,要先設置為塊級元素再設置居中
2016-12-09
因為input標簽不具有這個屬性