Learn how to create responsive floating elements with CSS.
Use media queries and set the specified screen width (in pixels) for when the element should float:
/* Float to the right on screens that are equal to or less than 768px wide */
@media (max-width: 768px) {
.float-right-sm {
float: right;
}
}
/* Float to the right on screens that are equal to or greater than 769px wide */
@media (min-width: 769px) {
.float-right-lg {
float: right;
}
}
Try it Yourself »
Tip: Learn more about floats in our CSS Float Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!