css - float 元素 : Different Max-Widths on Different Screens

标签 css mobile

我的网站 ( http://kawaiiface.net ) 的主要功能对 float 和最大宽度的运行情况非常严格。我的侧边栏插槽是 float: left;float: right; ,我的内容按钮是 margins: auto;。在桌面屏幕尺寸上,所有内容都会根据彼此的关系进行响应定位——但在移动上,侧边栏显示在内容的上方

考虑到算法更新,我已经开始为所有内容添加响应式容器:我的侧边栏运行 max-width: 160px;width: 100%; 到 1. 将它们保持在应有的位置和 2. 允许它们在较小的屏幕上响应。不过,这导致了一个问题——最大宽度允许我的容器很好地适应并在桌面上提供适当的 UE,它们会阻止插槽扩展到足以填满移动设备上的整个屏幕!

当我的左浮动元素位于它自己的 block 中时(也就是在较小的屏幕上高于其他所有内容),我如何删除我的最大宽度参数? Here is an image to help .

非常感谢!!

最佳答案

使用媒体查询的例子

有用的网站:https://css-tricks.com/css-media-queries/

示例:

/* Smartphones (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
/* Styles for smartphones here */
}

/* Smartphones (landscape) ----------- */
@media only screen 
and (min-width : 321px) {
/* Styles for smartphones here */
}

/* Smartphones (portrait) ----------- */
@media only screen 
and (max-width : 320px) {
/* Styles for smartphones here */
}

/* iPads (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {

/* Styles for ipad here */
}

/* iPads (landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {

/* Styles for ipad landscape here */
}

/* iPads (portrait) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
/* Styles for upad here */
}

/* Desktops and laptops ----------- */
@media only screen 
and (min-width : 1224px) {
      /* desktops and laptops style goes here */ 
}

/* Large screens ----------- */
@media only screen 
and (min-width : 1824px) {
/* Styles for large screen here *?
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {}

将此添加到您的 css 顶部,在每个 {} 内,您可以根据设备宽度的尺寸更改元素。根据您的目标设备,种类繁多,但范围很广。

关于css - float 元素 : Different Max-Widths on Different Screens,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29332317/

相关文章:

html - 使用 Sandbags 在 Chrome/Safari 中文本覆盖图像,而不是 FF 或 IE

html - 对齐按钮和输入的右侧

jquery - 无限图像从右到左滚动

ios - 从 visual studio 2013 运行 xamarin.ios 应用程序?

javascript - 网页高度超过视口(viewport)高度时的 CSS 属性

ios - HTML 输入 jQuery UI 日期选择器与 iOS 原生日期输入

mobile - 如何创建可以识别来自 CAM 的 2D 图像的位置/方向的移动应用程序

c# - 二维程序世界生成的动态多维数组

mobile - Asterisk 中的外部队列成员

javascript - jquery 等高需要与浏览器调整大小一起使用