2017-08-29 40 views
0

我想將類important放置在頁面的右上角,並使用垂直滾動條來控制溢出。更改important的寬度不起作用,所以滾動條當前正在顯示,但沒有任何操作,因爲沒有溢出。這是爲什麼發生?調整寬度沒有任何作用

<div class="important"> 
    <p>It's important to have some knowledge of CSS positioning. But 
    you will <em>not</em> be an expert after just a few simple examples!</p> 
</div> 

div.important { 
position: absolute; 
top: 0; 
right: 0; 
overflow-y: scroll; 
width: 50 px; 
} 

回答

0

overflow-y: scroll;空間將始終顯示滾動條,即使沒有什麼滾動。將其更改爲overflow-y: auto;應確保只有一個滾動條,如果有溢出。