Why does this list not move to the topright of the screen?
ul {
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
top: 10px;
right: 10px;
float: right;
}
li {
display: inline-block;
margin-right: 10px;
}
I don't know why float:right; doesn't fix this
Because by default the
ulis 100% wide, sofloat:righthas no visible effect on it since it fills the whole width of the container. Thelis are left-aligned inside theul.You can add a
widthsetting to theul(i.e. 50%, or a fixed pixel value), then you'll see the effect of thefloat:right.