我想box-sizing: border-box
爲div
標記。box-sizing:border-box => for IE8?
對於Mozila Firefox的我曾嘗試
-moz-box-sizing: border-box;
對於IE(Internet Explorer)中我曾嘗試以下兩種或者
-ms-box-sizing: border-box;
box-sizing: border-box;
,但它不能在IE 作品(Internet Explorer)。 雖然我已爲應用box-sizing: border-box;
Internet Explorer它在元素的寬度上添加了邊框和填充。爲什麼會發生?
應該是什麼問題?請幫助並消化我。
注:我使用互聯網Explorer8和Windows7旗艦版
頁面代碼:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MainPage.aspx.cs" Inherits="MainPage" %>
<!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 runat="server">
<meta http-equiv="x-ua-compatible" content="IE=8"/>
<title></title>
<style type="text/css">
*
{
box-sizing: border-box; /*it gives error:Validation (CSS 2.1): 'box-sizing' is not a known CSS property name. */
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body
{
background: lightblue;
color: #000000;
font-family: Trebuchet MS, Arial, Times New Roman;
font-size: 12px;
}
#header
{
background: #838283;
height: 200px;
width: 1200px;
}
#wrapper
{
background: #FFFFFF;
margin: 0px auto;
width: 1200px;
height: 1024px;
}
#navigation
{
background: #a2a2a2;
float: left;
margin: 0px 0px;
width: 1200px;
height: 25px;
padding: 3px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
<div id="header">
<h1>
Header goes here</h1>
<br />
<h2 style="font-size: 60px;">
ST ERP by Shanti Technology</h2>
</div>
<div id="navigation">
</div>
</div>
</form>
</body>
</html>
驗證錯誤是無關緊要的 - 'box-sizing'是CSS3的一部分,而不是CSS2.1。如果您真的關心驗證,請注意,前綴不會針對任何版本的CSS進行驗證。 – BoltClock 2012-07-23 08:11:11
我可以更改CSS版本嗎? – Pritesh 2012-07-23 08:14:01
你檢查了我的答案嗎? -ms-box-sizing:border-box;不需要 – Dipak 2012-07-23 08:15:24