【问题标题】:CSS for a mobile then converting to tablet, desktop, and a larger desktop用于移动设备的 CSS,然后转换为平板电脑、台式机和更大的台式机
【发布时间】:2015-03-17 00:53:32
【问题描述】:

我开始为移动设备 (iPhone 5c) 编写代码,然后在我的媒体查询部分中,我添加了更多适用于更大尺寸的代码:平板电脑 (768px)、桌面 (1024px) 和更大的桌面 (1200px) )。

在为移动部分编写代码时,我正在将自己桌面上的窗口宽度(使用谷歌浏览器)缩小到在编写代码时可以达到的最大宽度。但是,当我在插入 URL 的情况下查看手机和 iOS 模拟器时,它显示为平板电脑版本。它不应该在移动设备上将背景颜色设为“红色”,而只能在平板电脑上使用。

基本上:移动 - 不是红色的。平板电脑 - 红色

当我将它插入手机时,它不应该是红色的。它看起来像平板电脑版本。

如果有人可以帮助我,我将不胜感激!

这是我的网址:alyssamroth.com/responsive01.html

到目前为止,这是我的代码:

html {
    background-color: #e9e9e9;
}

body {
    font-family: "aktiv-grotesk-std",sans-serif;
    margin: 0 auto;
    width: 100%;
}

#wrapper {
    margin: 0 auto;
    overflow: hidden;
}

/*=================== HEADER======================== */


nav {
    height: 100px;
    background-color: #e54f26;
    /*padding: 0 0px 0 0px;*/
}

nav #logo {
    margin-left: 20px;
    margin-top: 20px;
}

nav #contactIcon {
    margin-right: 20px;
    margin-top: 35px;
    float: right;
}

header #mountains {
    width: 100%;
    height: 350px;
    background-image: url(../img/mountain.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    margin-bottom: 40px;
    margin-top: 0px


}

header h1 {
    color: white;
    font-size: 2.7em;
    margin-left: 55px;
    padding-top: 150px;
    font-family: "aktiv-grotesk-std", sans-serif;
    font-weight: 900;
    font-style: normal;
}

header h2 {
    padding-top: 2px;
    letter-spacing: 15px;
    color: #a7a8ad;
    font-size: 2.1em;
    margin-left: 100px;
    font-family: "aktiv-grotesk-std", sans-serif;
    font-weight: 300;
    font-style: normal;
    padding-bottom: 200px;
}


/* ========== CONTENT ============= */


article h3 {

    font-size: 1.8em;
    color: #101626;
    margin-left: 20px;
    margin-bottom: 20px;
    font-family: "aktiv-grotesk-std", sans-serif;
    font-weight: 200;
    font-style: normal;

}


p {

    margin-left: 20px;
    font-size: 1.2em;
    margin-right: 20px;
    color: #101626;
    line-height: 30px;
    font-family: "aktiv-grotesk-std", sans-serif;
    font-weight: 400;
    font-style: normal;
    padding-bottom: 20px
}

aside #ipad {
    padding-top: 76px;
}

aside #desktop {
    padding-top: 82px;
}

aside #phone {
    padding-top: 82px;
}

/* =============== Media Query for Tablets ===============*/
@media only screen and (min-width: 768px) {

body {
    background-color: red

}


/* =============== Media Query for Desktops ===============*/
@media only screen and (min-width: 1024px) {

}


/* =============== Media Query for Large Desktops ===============*/
@media only screen and (min-width: 1200px) {

【问题讨论】:

  • Alyssa 您的代码似乎正在按应有的方式工作。您将平板电脑版本的媒体查询中的背景颜色更改为红色,该颜色将应用于大于该大小的所有内容。也许我不明白你的问题。
  • 我重新表述了这个问题,希望你现在可以理解了。

标签: mobile size media desktop tablet


【解决方案1】:

这就是我所看到的,看看我的截图: 移动 - 非红色 平板电脑 - 红色

【讨论】:

    猜你喜欢
    • 2015-11-16
    • 2018-11-05
    • 2021-11-24
    • 1970-01-01
    • 2011-09-16
    • 2021-02-04
    • 2019-06-25
    • 1970-01-01
    • 2021-01-06
    相关资源
    最近更新 更多