平板电脑/移动设备的 CSS 条件,而不仅仅是 <!--[if IE]>?

标签 css cross-browser conditional-statements

我制作了一个在所有浏览器中都能正常显示的网站,但在手机或平板电脑上查看时,其粗细为 font-weight: 100; 的 body 字体就很好了。

有没有一种方法可以编写一个 css 条件来定位手机和平板电脑,类似于 IE 条件?

<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->

最佳答案

您应该使用媒体查询:http://www.w3.org/TR/css3-mediaqueries/

示例(引自 Bootstrap 网站):

/* Large desktop */
@media (min-width: 1200px) { ... }

/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 979px) { ... }

/* Landscape phone to portrait tablet */
@media (max-width: 767px) { ... }

/* Landscape phones and down */
@media (max-width: 480px) { ... }

关于平板电脑/移动设备的 CSS 条件,而不仅仅是 &lt;!--[if IE]>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15395135/

相关文章:

jquery - 用 jquery 改变几个 div css onload (this)

javascript - 处理 Bootstrap 翻转卡中的点击事件

angularjs - Angular 应用程序在 Firefox 中中断

css - slim 过渡可以有条件吗?

php - WooCommerce 成员(member)资格 : Conditional to check a page access

css - 制作 3 个响应列?

html - CSS 列无法正常工作

html - 为什么不溢出 :hidden working in IE6?

javascript - mousemove 和跨浏览器 e.which

css - 如果用户通过移动设备查看,我可以删除插件吗?