简体   繁体   English

具有固定定位和浮动的 div

[英]div with fixed positioning and float

I have the following code:我有以下代码:

http://jsfiddle.net/dbg5X/ http://jsfiddle.net/dbg5X/

Is it possible to have the second div to be in a fixed position and to have it float to the right?是否可以将第二个 div 放在固定的 position 中并让它向右浮动?

Thanks,谢谢,

Floating and positioning are two totally different models for arranging stuff on the screen, and they don't mix.浮动和定位是两种在屏幕上排列东西的完全不同的模型,它们不会混合。

Try putting right: 10px on the second div.尝试将right: 10px放在第二个 div 上。

No, you can't have a single element at a fixed position and float at the same time because float means not having a fixed position.不,您不能在固定的 position 上拥有单个元素并同时浮动,因为浮动意味着没有固定的 position。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM