簡體   English   中英

max-width HTML屬性在IE和Firefox中不起作用,但在Chrome中

[英]max-width HTML property is not working in IE and Firefox, but it is in Chrome

我定義了一個表,該表使用頁面的整個寬度width="100%"並且要定義其中的圖像,這些圖像的最大寬度與表的max-width="100%"
但是它不適用於IE和Firefox!
我已經讀到,如果不為表格定義寬度,則這些導航器將不被視為max-width屬性,但是,我該怎么做才能獲得所需的信息?

好的,我正在編輯我的原始問題,使其更具體:HTML代碼(即“ paco.html”):

<!doctype html>
<html>
<head>
 <link rel="stylesheet" href="myStyles.css"/>
</head>
<body>
 <table>
  <tr>
   <td><img src="myImage.png"></td>
  </tr>
 </table>
</body>
</html>

現在,CSS代碼(myStyles.css):

table, td{
  width: 100%;
}
table td img{
  max-width: 100%;
  height: auto;
}

...這就是全部。

max-width屬性是CSS而不是HTML,您必須將其放入CSS或說: <img src="#" style="max-width: 666px;>

有關最大寬度檢查的更多信息: MDN

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM