[重要提示:這隻會影響自託管<video>
標籤,而不是YouTube或VIMEO I幀]是否可以在Wordpress中使*肖像* <video>標籤響應?
所以我嵌入網頁的手機視頻與垂直比(縱向)(通常爲720像素寬,1280px高度)。
一切正常,除了視頻不適應頁面。寬度將適合,但用戶需要在視頻播放時上下滾動以欣賞正在顯示的內容。
我試過所有的CSS技巧,使視頻分區響應,但它不會工作。
的視頻被包裝成一個div其內容如此:(!只有寬度似乎適應的頁面尺寸改變)
.wp-video-shortcode, video, .mejs-mediaelement {
max-width: 100% !important;
max-height:100% !important;
}
但沒有效果。
如果我手動改變短碼的寬和高,像這樣:
[video width="720" height="1280" mp4="http://url.mp4" autoplay="true" poster="http://url.jpg"][/video]
成爲
[video width="340" height="680" mp4="http://url.mp4" autoplay="true" poster="http://url.jpg"][/video]
視頻變小,但仍然無法適應頁面。
我想我已經明白了爲什麼......?告訴我,如果我偏離了軌道:
的<video>
嵌入在WordPress的是如何大小的整體前提,似乎是基於width
:甚至還有叫$content_width
用於此目的的全局變量,雖然沒有$content_height
。
具體來說,這是在wp_video_shortcode
功能會發生什麼:
global $content_width;
// if the video is bigger than the theme
if (! empty($content_width) && $atts['width'] > $content_width) {
$atts['height'] = round(($atts['height'] * $content_width)/$atts['width']);
$atts['width'] = $content_width;
}
,你可以在上面看到,WP似乎只被檢查視頻僅針對頁面的寬度。
這怎麼解決?