Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Foundation CSS Visibility

Foundation CSS Visibility


Displaying elements based on screen size

The following classes display elements based on the device (screen size).

class Description
.show-for-small-only Display elements only on small devices (screen width less than 40.0625em)
.show-for-medium-up Display elements on medium and larger devices (screen width greater than 40.0625em)
.show-for-medium-only Display elements only on medium devices (screen width between 40.0625em and 64.0625em)
.show-for-large-up Display elements on large and larger devices (screen width greater than 64.0625em)
.show-for-large-only Display elements only on large devices (screen width between 64.0625em and 90.0625em)
.show-for-xlarge-up Display elements on larger and larger devices (screen width greater than 90.0625em)
.show-for-xlarge-only Display elements only on larger devices (screen width between 90.0625em and 120.0625em)
.show-for-xxlarge-up Display elements on extra-large and larger devices (screen width greater than 120.0625em)

The following examples demonstrate all the above .show- classes' visibility.



你在小型设备上。

你在中型、大型、更大型、超大型的设备上。

你在中型设备上。

你在大型、更大型、超大型的设备上

你在大型设备上。

你在更大型、超大型的设备上。

你在更大型设备上。

你在超大型设备上。

Try it »


Hiding elements based on screen size

The following classes hide elements based on the device (screen size).

class Description
.hide-for-small-only Hide elements only on small devices (screen width less than 40.0625em)
.hide-for-medium-up Hide elements on medium and larger devices (screen width greater than 40.0625em)
.hide-for-medium-only Hide elements only on medium devices (screen width between 40.0625em and 64.0625em)
.hide-for-large-up Hide elements on large and larger devices (screen width greater than 64.0625em)
.hide-for-large-only Hide elements only on large devices (screen width between 64.0625em and 90.0625em)
.hide-for-xlarge-up Hide elements on larger and larger devices (screen width greater than 90.0625em)
.hide-for-xlarge-only Hide elements only on larger devices (screen width between 90.0625em and 120.0625em)
.hide-for-xxlarge-up Hide elements on extra-large and larger devices (screen width greater than 120.0625em)


你不在小型设备上。

你不在中型、大型、更大型、超大型的设备上。

你不在中型设备上。

你不在大型、更大型、超大型的设备上。

你不在大型设备上。

你不在更大型、超大型的设备上。

你不在更大型设备上。

你不在超大型设备上。

Try it »


Displaying elements based on screen orientation

The following classes hide elements based on the device (screen size).

We can set whether elements are shown or hidden in different orientations. Desktop devices such as laptops are generally landscape, but phones and tablets can be landscape or portrait; we can set elements to be hidden or shown based on the orientation in which the user holds their phone:

class Description
.show-for-landscape Display elements in landscape orientation (hidden in portrait)
.show-for-portrait Display elements in portrait orientation (hidden in landscape)

The following example displays text content based on the orientation used:

Example

<

p

class=

"show-for-landscape"

The text is displayed only in landscape.

<

/p

<

p

class=

"show-for-portrait"

The text is displayed only in portrait.

<

/p

Try it »


Showing and hiding on touch devices

You can show or hide elements based on whether the device supports touch.

class Description
.show-for-touch Show on touch-enabled devices (hidden on devices that do not support touch)
.hide-for-touch Hide on touch-enabled devices (shown on devices that do not support touch)

The following example displays text content based on whether the device supports touch:

Example

<

p

class=

"show-for-touch"

Your device supports touch.

<

/p

<

p

class=

"hide-for-touch"

Your device does not support touch.

<

/p

Try it »