KrMa
KrMa

Reputation: 713

Different between landscape and portrait Media Query

I am sitting and reading on this page

Media Query

It says here:

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

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

But there is no difference in those two codes? That result in that I make my elements fit on fx landscape mode. Then I go to Portrait mode, and everything is flying around.

How can I design the responsive, so I seperate Portrait and Landscape mode?

CSS

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

    .ebook-image {
    width: 600px;
    display: block;
    margin: 0 auto;
    margin-top: -30px;
    }

    .ebook-image img {
        margin-left: 0px;
    }

    .header-box {
        background-color: #163A4E;
        height: 680px;
        margin-bottom: 0px;
        padding: 0px;
    }

    .header-text h1 {
        font-weight: 900;
        font-size: 40px;
        line-height: 1;
        text-transform: uppercase;
        color: #fff;
        position: relative;
        left: 0px;
        top: -10px;

    }

    .header-text h2 {
        font-size: 20px;
        margin-bottom: 25px;
        font-weight: 900;
        color: #fff;
        position: relative;
        left: 0px;
        top: -30px;
        text-align: center;
    }

}

 iPads (landscape) ----------- 
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
    .ebook-image {
        height: 500px;
        width: 590px;

    }

    .ebook-image img {
        margin-left: -190px;
        padding-top: 0px;

    }
    .header-box {
        background-color: #163A4E;
        height: 350px;
        margin-bottom: 0px;
        padding: 0px;
    }

    .header-text h1 {
        font-weight: 900;
        font-size: 40px;
        line-height: 1;
        text-transform: uppercase;
        color: #fff;
        position: absolute;
        left: -400px;
        top: 110px;

    }

    .header-text h2 {
        font-size: 20px;
        margin-bottom: 25px;
        font-weight: 900;
        color: #fff;
        position: absolute;
        left: -405px;
        top: 150px;

    }
}

Upvotes: 0

Views: 2759

Answers (2)

bmfteixeira
bmfteixeira

Reputation: 134

@media (min-width: 700px) and (orientation: landscape)

This way you make sure you combine a min-width with the orientation of the device. You can (and should) use the orientation markup for your layouts if you have different behaviours.

Upvotes: 1

PitchBlackCat
PitchBlackCat

Reputation: 555

The queries are quite different; note the trailing and (orientation : landscape) and and (orientation : portrait) in both media queries.

Here's a fiddle that demonstrates these queries by applying a different background color when viewed in landscape or portrait mode. https://jsfiddle.net/dem49e87/2/show/

Make sure to open it on your phone and check it out in both portrait and landscape mode.

Upvotes: 2

Related Questions