Html 调整宽度没有任何作用

Html 调整宽度没有任何作用,html,css,Html,Css,我想把classimportant放在页面的右上角,并用一个垂直滚动条来控制溢出。更改important的宽度没有任何作用,因此滚动条当前正在显示,但没有任何作用,因为没有溢出。为什么会这样 <div class="important"> <p>It's important to have some knowledge of CSS positioning. But you will <em>not</em> be an exper

我想把class
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;
}

对CSS定位有一些了解是很重要的。但是
仅仅举几个简单的例子,你就不是专家了

重要部门{ 位置:绝对位置; 排名:0; 右:0; 溢出y:滚动; 宽度:50像素; }
删除宽度为50px的空间
溢出-y:滚动将始终显示滚动条,即使没有可滚动的内容。将其更改为
overflow-y:auto应确保只有一个滚动条溢出