Javascript JQuery箭头键滑块的东西
好吧,很抱歉这个标题,我想不出该怎么称呼它 我正在用HTML5和JavaScript设计一个智能电视界面。到目前为止,我得到的是一个Javascript JQuery箭头键滑块的东西,javascript,jquery,html,css,Javascript,Jquery,Html,Css,好吧,很抱歉这个标题,我想不出该怎么称呼它 我正在用HTML5和JavaScript设计一个智能电视界面。到目前为止,我得到的是一个div,里面全是假电影名(用于测试目的)。我不认为它一直在运行,但这里有一个演示: 我想做的是检测所选的div是否在其类的第三个到第一个div和第三个到最后一个div之间。如果是,我希望包含div的整个左值移动-230px 我算出了这个方程式。虽然不起作用,但你应该有这个想法 (index - 2) * -220 + "px" 我试过很多东西,但都不管用 这是我的
div
,里面全是假电影名(用于测试目的)。我不认为它一直在运行,但这里有一个演示:
我想做的是检测所选的div
是否在其类的第三个到第一个div和第三个到最后一个div
之间。如果是,我希望包含div的整个左值移动-230px
我算出了这个方程式。虽然不起作用,但你应该有这个想法
(index - 2) * -220 + "px"
我试过很多东西,但都不管用
这是我的密码
JS:
Html:
我需要添加什么?您能在这里添加一些相关的HTML,以在可运行的代码中创建一个完整的示例吗?否则,如果你的链接断了,这个问题就无法回答。只花了6分钟在css的每一行前面加空格。最后四行,它告诉我我可以按ctrl+k,它可以帮我。对不起,我为你修正了它。你能在这里添加一些相关的HTML,在一个可运行的代码中创建一个完整的示例吗?否则,如果你的链接断了,这个问题就无法回答。只花了6分钟在css的每一行前面加空格。最后四行,它告诉我我可以按ctrl+k,它可以帮我。对不起,我帮你修好了
var selected;
$(document).ready(function() {
$(".movie-section .movie:nth-child(1)").addClass("movie-selected");
selected = $(".movie-selected");
$('html').keydown(function(e){
if (e.keyCode == 39) {
if (selected.is($(".movie-section .movie:last-child"))) {
} else {
$( ".movie-selected + .movie" ).addClass("movie-selected");
$( selected ).removeClass("movie-selected");
selected = $(".movie-selected");
}
}
if (e.keyCode == 37) {
if (selected.is($(".movie-section .movie:nth-child(1)"))) {
} else {
$( ".movie-selected" ).prev().addClass("movie-selected");
$( selected ).removeClass("movie-selected");
selected = $(".movie-selected");
}
}
});
});
<!DOCTYPE html>
<html ng-app="homeApp">
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<title>XViuw</title>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/parallax.min.js"></script>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div class="parallax-window" data-parallax="scroll" data-image-src="img/blurcity.png"></div>
<div ng-controller="Controller as controller">
<header class="headerbar">
</header>
<div class="movie-section">
<div ng-repeat="movie in movies" class="movie">
<div class="thumbnail">
<img ng-src="{{ movie.cover }}">
<p class="title">{{ movie.name }}</p>
<p>{{movie.rating}}</p>
<p>{{movie.length}}</p>
</div>
</div>
</div>
</div>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Roboto);
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../fonts/MaterialIcons-Regular.ttf);
}
body, html {
width: 100%;
height: 100%;
font-family: 'Roboto', sans-serif;
margin: 0;
}
.parallax-window {
min-height: 100%;
background: transparent;
}
.headerbar {
width: 100%;
height: 100px;
position: fixed;
top: 0;
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
.movie-section {
height: 200px;
position: fixed;
top: 140px;
left: 0;
white-space: nowrap;
font-family: 'Roboto', sans-serif;
-webkit-transition: left 300ms, right 300ms;
transition: left 300ms, right 300ms;
}
.movie {
margin: 0 10px;
width: 180px;
height: 180px;
padding: 10px 20px;
text-align: center;
color: white;
display: inline-block;
border-radius: 2px;
-webkit-transition: background 150ms;
transition: background 150ms;
}
.movie-selected {
background: white;
color: #5f5f5f;
}
.movie-selected:hover {
background: white !important;
}
.title {
text-overflow: ellipsis;
width: 175px;
white-space: nowrap;
overflow: hidden;
}
.movie:hover {
background: rgba( 0, 0, 0, 0.4);
}
.thumbnail > img {
width: 160px;
height: 100px;
}
.thumbnail > p {
margin: 0;
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
width: 1em;
height: 1em;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}