Sai*_*lam 1 html css css-position
右列固定位置适用于Opera和Firefox但不适用于Chrome,任何解决方案?
#rightcolumn {
margin: 0px 0px 0px 0px;
float: right;
font-family: Arial;
font-weight: bold;
height: auto;
width: 300px;
display: inline;
position: fixed;
}
Run Code Online (Sandbox Code Playgroud)
Spa*_*rky 12
1)首先,删除display: inline因为,如果你想要块级元素position: fixed,你也不能拥有它inline.甲fixed位置元件是正常的流的外侧,因此,根据定义,不能同时是内联.
2)其次,删除,float: right因为你想要它fixed. 根据规范,它不可能两者兼而有之.
"......如果'position'的值为'absolute'或'fixed',则该框绝对定位,'float'的计算值为'none'..."〜W3C spec
3)最后,当使用absolute或fixed(fixed是absolute 根据规范的子集)时,通过添加类似的东西来设置元素的位置,top: 0;并将right: 0;其相对于其父元素的边缘放置.
#rightcolumn {
margin: 0;
font-family: Arial;
font-weight: bold;
height: auto;
width: 300px;
position: fixed;
top: 0; <-- adjust accordingly
right: 0; <-- adjust accordingly
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20408 次 |
| 最近记录: |