2017-01-18 1 views
0

호버를 확장하기 위해 비디오를 얻으려고하고 있지만 작동하지 않고 지혜로 끝납니다.호버상에서 비디오 확장하기

당신이 사용하려고 할 수 있습니다

$("#wd1").mouseenter(function() { 
 
\t vid = document.getElementById("wd1"); 
 
\t posTop = $("#wd1").offset().top; 
 
\t posLeft = $("#wd1").offset().left; 
 
\t vidWidth = vid.clientWidth; 
 
\t vidHeight = vid.clientHeight; 
 
\t $("#wd1").remove(); 
 
\t vidPlayer = document.createElement('div') 
 
\t vidPlayer.setAttribute("id", "vpId"); 
 
\t vidPlayer.style.position = "relative"; 
 
\t vidPlayer.style.backgroundColor = "rgba(0,0,0,0.9)" 
 
\t vidPlayer.style.marginTop = posTop; 
 
\t vidPlayer.style.marginLeft = posLeft; 
 
\t vidPlayer.innerHTML = '<video src="public_html/media/VerifiableTerrificHind.mp4" width="'+vidWidth+'" height="'+vidHeight+'" autoplay loop type="video.mp4">'; 
 
\t document.getElementsByTagName('body')[0].appendChild(vidPlayer); 
 
\t $("#vpId").hide().fadeIn(2000); 
 
\t $("#vpId").animate({width: "100%", height: "auto"}, 500); 
 
});
#wd1:hover { 
 
\t z-index:1000; 
 
\t margin: 0 auto; 
 
\t width: 50vw; 
 
\t height: auto; 
 
\t display: block; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
<div class="container-fluid"> 
 
\t <div class="row"> 
 
    <div id="box"></div> 
 
\t \t <div class="col-lg-10 col-lg-offset-1"> 
 
    \t \t <div class="row" id="vpDiv"> 
 
      \t <div class="col-lg-3"> 
 
     <video id="wd1" src="https://matthew-williams.000webhostapp.com/media/VerifiableTerrificHind.mp4" alt="my image" width="100%" height="auto" data-video="https://matthew-williams.000webhostapp.com/media/VerifiableTerrificHind.mp4" type="video/mp4"> 
 
\t \t \t \t </div> 
 
    \t \t \t </div> 
 
\t \t </div> 
 
\t </div> 
 
</div>

https://www.jsnippet.net/snippet/1300/

+0

죄송합니다. 브라우저의 현재 위치부터 시작하여 수직 및 수평 가운데로 확장해야합니다. –

답변

0

(w Dreameaver의 CC 2015/부트 스트랩 사용) :

#wd1:hover { 
    z-index:1000; 
    margin: 0 auto; 
    width: 50vw; 
    height: auto; 
    display: block; 
    transform: translateX(25%) translateY(25%); 
    -webkit-transform: translate(25%, 25%); 
    -webkit-transition: all 0.2s linear; 
     -moz-transition: all 0.2s linear; 
     -ms-transition: all 0.2s linear; 
     -o-transition: all 0.2s linear; 
      transition: all 0.2s linear; 
} 

당신은 값 주위에 재생할 수 있습니다 translateX()translateY().

+0

감사합니다. Jerred. 이러한 변경 사항을 몇 가지 위치, display 및 zIndex 속성 변경과 함께 구현하고 일부 스크립트 행을 제거하면 css : hover 문제가 남습니다. css : hover를 사용하면 사용자 마우스가 비디오를 따라야 정상적으로 표시됩니다. jquery를 사용하여 원래의 비디오를 제거하고 원래의 사용자 위치에서 시작하는 새 비디오를 생성하는 이유는 무엇입니까? 비디오를 새 div에 넣고 확장합니다 (예 : .mouseenter() 만 사용하고 닫기 버튼이 있음). –

관련 문제