Elementor 开发者文档

title: "Viewport Content" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Hello Elementor Theme - Src - Repos


Viewport Content

The theme has a viewport meta tag, in the head, that controls the viewport's size and shape. Developers can modify the content attribute of the meta tag using a filter hook in a child-theme.

Hook Details

The hook controls the content of the viewport meta tag. By default the viewport width is set to the device-width and the initial scale is set to 1:

<meta name="viewport" content="width=device-width, initial-scale=1">

Usage

To modify the viewport content, use the following hook in a child-theme functions.php file:

function custom_hello_elementor_viewport_content() {
    return 'width=100vw, height=100vh, user-scalable=no';
}
add_filter( 'hello_elementor_viewport_content', 'custom_hello_elementor_viewport_content' );

The result:

<meta name="viewport" content="width=100vw, height=100vh, user-scalable=no">