cyf-123456 发表于 2013-2-7 19:02:50

overflow hidden 隐藏超出元素

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
 *{padding:0px; margin:0px;}
 .d1{width:600px;float:left; display:inline;border:1px solid #CC3300;}
 .d1 dl{float:left;width:600px;}
 .d1 dl dd{width:299px;float:left;height:23px;line-height:23px;margin-top:10px;display:inline;  overflow:hidden;}
 .d1 dl dd span{float:left;width:90px;height:23px;line-height:23px; background-color:#003333; color:#FF0000; text-align:center;}
 .d1 dl dd em{ float:right;display:block;width:200px; margin-top:2px;}
</style>
</head>
<body>
<div class="d1">
    <dl>
        <dd><span>姓名:</span><em>cyf</em><em><select> <option>sss</option> </select> </em> </dd>
        <dd><span>性别:</span><em>nan</em><em><select> <option>sss</option> </select> </em></dd>
       
        <dd><span>年龄:</span><em><select> <option>sss</option> </select> </em> </dd>
        <dd><span>工资:</span><em><select> <option>sss</option> </select> </em></dd>
    </dl>
</div>
</body>
</html>
 
使用overflow: hidden的前提,我想两个标签都应该代表块状的,想span,em本身是行内元素,只能通过display:block 和float:left;强制转换成块,又强制性的在一行,overflow: hidden,使得超出dd宽度的em元素自动隐藏
页: [1]
查看完整版本: overflow hidden 隐藏超出元素