An warware: idan girman allo

Babban matsalar da ke da alaฦ™a da faษ—in allo shine yana iya zama da wahala a ฦ™irฦ™ira shimfidu waษ—anda ke da kyau akan duk na'urori. Misali, idan kuna son shimfidar wuri mai kyau akan kwamfutar tebur, maiyuwa baya yi kyau akan waya ko kwamfutar hannu.

 is less than 768px

if (screen.width < 768) {
    // do something
}

Wannan lambar tana duba idan girman allon bai wuce 768px ba. Idan haka ne, to zai aiwatar da lambar a cikin takalmin gyaran kafa mai lanฦ™wasa.

Kaddarorin allo na JavaScript

A cikin JavaScript, ana amfani da kaddarorin allo don samun bayani game da allon na yanzu. Ana iya samun dama ga kaddarorin allo ta amfani da dukiyar taga.screen. Tebu mai zuwa yana lissafin mafi yawan kaddarorin allo a cikin JavaScript.

Bayanin Dukiyar allo

taga.screen.nisa Faษ—in allon na yanzu a cikin pixels.

taga.screen.tsawo Tsawon allo na yanzu a cikin pixels.

taga.screen.depth Zurfin allon na yanzu a cikin pixels (0 = surface, 1 = bitmap).

Nau'in allo tare da JavaScript

Nau'in allo shine javascript.

Shafi posts:

Leave a Comment