M
M
Margo19642017-04-04 12:33:52
css
Margo1964, 2017-04-04 12:33:52

JS or CSS: How to detect phone orientation? Horizontal? Vertical? Media queries? JavaScript?

What is the most correct way to determine the phone's sweep on the fly. It is required to display a message about the need to turn the phone if it is located vertically and remove it if the phone is turned.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Margo1964, 2017-04-04
@Margo1964

@media screen and (orientation:portrait) {}
@media screen and (orientation:landscape) {}

R
Rikcon, 2017-04-04
@Rikcon

caniuse.com/#feat=screen-orientation
I don't even know... there is a csse

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

but as you can see, ios safari is in no hurry to digest this matter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question