2013-03-18 154 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%+利潤