2013-03-18 249 views
1

你好。我的问题是,我希望.mylargeframe在整个浏览器宽度范围内。继承CSS宽度

CSS

.mylargeframe { 
    background: linear-gradient(top, #fff, #f8f8f8); 
    border: 1px solid #d0d2d5; 
    border-bottom: 1px solid #bebfc2; 
    border-radius: 4px; 
    margin: 0 0 20px 0; 
    padding: 20px; 
    width: 80%; 
    overflow: auto; 
} 

fieldset { 
    background:#ebeced; 
    border: none; 
    border-top: 1px solid #d0d2d5; 
    border-radius: 0 0 4px 4px; 
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75); 
    margin: 5px 0 -20px -20px; padding: 18px 20px; 
    width: auto; 
} 

fieldset input { 
    margin: 0; 
    width: auto; 
} 

HTML

<html> 
    <div class="mylargeframe"> 
    <fieldset> 
    test 
    </fieldset> 
    </div> 
</html> 

的问题是,它没有完全填充,但它几乎没有。我正在使用Firefox和Chrome

+1

你'宽度:80%' '.mylargeframe'。为什么你会期望它整个走? – 2013-03-18 03:22:45

回答

4

width: auto;替换为fieldset100%。现在

fieldset 
{ 
    background:#ebeced; 
    border: none; 
    border-top: 1px solid #d0d2d5; 
    border-radius: 0 0 4px 4px; 
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75); 
    margin: 5px 0 -20px -20px; padding: 18px 20px; 
    width: 100%; 
} 

,该fieldset会占用其父的width

0

这样Fieldset将填补你的DIV;)

fieldset 
{ 
    width:100%; 
    -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ 
    -moz-box-sizing: border-box; /* Firefox, other Gecko */ 
    box-sizing: border-box;   /* Opera/IE 8+ */ 
} 

你需要盒大小,否则宽度将是100%+利润