【发布时间】:2013-01-24 22:06:40
【问题描述】:
我的宽度有问题:20%;被我的最小宽度覆盖:30px; (参见css框中的第22和23行:http://jsfiddle.net/dLmnX/)
我也是第一次使用纵横比:我从http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio 中提取并切碎了代码。
代码的纵横比部分:
#aspect {
padding-top: 120%; /* aspect ratio */
}
似乎工作正常,它只是这个 div 中的宽度:
#shuffle1 {
display: inline-block;
margin: 0px auto;
position: relative;
width: 20%;
min-width: 30px;
}
任何帮助都会很棒! 谢谢。
【问题讨论】:
-
您使用 div id
#shuffle1的次数过多。改为上课.shuffle1 -
id(#idName) 对于当前 HTML 文档必须是唯一的,而class(.className) 可以根据需要多次重复使用。#shuffle1和#two都被多次使用,这是不允许的。 -
谢谢!这只是不好的做法吗?还是会影响页面的结果?
-
它使文档无效。它不会影响 CSS,但如果您将 ids 用作 JavaScript 的钩子(例如
document.getElementById('two')-- 它会选择哪个?),则会引起很多混乱。
标签: html width aspect-ratio css