注册 登录
编程论坛 WEB前端(UI)

min-width不起作用但是min-height可以,谁能帮忙解答下

诸葛修勤 发布于 2013-11-20 23:40, 1538 次点击
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html>
<head>
<style type="text/css">
*{margin: 0; padding: 0; font-size: 12px;}
body{width: 1000px; height: 600px; border: 1px red solid;}
div{border: 4px rgb(201, 198, 233) solid; background: rgb(153, 153, 154);}
div.d1{position: relative; min-width: 20%; min-height: 10%;}
</style>
</head>
<body>
<div class="d1">
</div>
</body>
</html>
2 回复
#2
hugeannex2013-11-21 10:27
div默认的width是auto,意识里就是100%,你设个min-width最小宽度为20%,100%难道不大于20%?!!!!
你这样写就明白了:div.d1{position: relative; width:0; min-width: 20%; min-height: 10%;}

#3
诸葛修勤2013-11-21 18:41
换种写法
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>

 <html>

 <head>

 <style type="text/css">

 *
{margin: 0; padding: 0; font-size: 12px;}

 body
{width: 1000px; height: 600px; border: 1px red solid;}

 div
{border: 4px rgb(201, 198, 233) solid; background: rgb(153, 153, 154);}

 div.d1
{position: relative; min-width: 200px; min-height: 10%;}

 
</style>

 </head>

 <body>

 <div class="d1">

 </div>

 </body>

 </html>
1