html – Margin-top:100%得到父宽度值…奇怪

前端之家收集整理的这篇文章主要介绍了html – Margin-top:100%得到父宽度值…奇怪前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在大多数浏览器(即ff,chrome,safari)上,我有一个非常奇怪的“问题”.
这是示例代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <style type="text/css">
  6. html{
  7. outline: 1px #0ff solid;
  8. background: rgba(0,255,0.1);
  9. }
  10. body{
  11. margin: 0;
  12. padding: 0;
  13. outline: 1px #00f solid;
  14. background: rgba(0,0.1);
  15. }
  16. #aDiv{
  17. width: 300px;
  18. outline: 1px #f00 solid;
  19. background: rgba(255,0.2);
  20. }
  21. #bDiv{
  22. margin-top: 100%;
  23. outline: 1px #0f0 solid;
  24. background: rgba(0,0.1);
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div id="aDiv">
  30. <div id="bDiv">
  31. content
  32. </div>
  33. </div>
  34. </body>
  35. </html>

当您更改#aDiv宽度时,#bDiv margin-top将更改为相同的值.
我不知道它是如何可能的,高度是宽度.无论如何也许你可以解释一下我在做什么?

最好的祝福

猜你在找的HTML相关文章