Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setVideoCenter() {
- let $box = $('.slider-menu__slider-img_video');
- let height = $box.height();
- let width = $box.width();
- let new_height = width / 1.78;
- if (new_height > height) {
- $box.find('video').css({
- width: width,
- height: new_height,
- top: '0',
- left: '0',
- });
- } else {
- let new_width = height * 1.78;
- $box.find('video').css({
- width: new_width,
- height: height,
- top: '0',
- left: '-' + (new_width / 2 - width / 2) + 'px'
- });
- }
- }
- $(function(){
- setVideoCenter();
- $(window).resize(setVideoCenter);
- });
Advertisement
Add Comment
Please, Sign In to add comment