- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试显示数组中的动漫列表。我已经使用“oredrby”过滤器对列表进行了排序。每次添加新行时,我都想自动滚动到列表中最后插入的行。请注意,我不想自动滚动到列表底部。这是
演示我的问题。
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<title>Angular App</title>
<style>
body{
font-family: Verdana;
font-weight: bold;
display: flex;
justify-content: center;
overflow: auto;
}
div{
width: 100%;
}
li{
position: relative;
animation: drop 0.7s;
cursor: pointer;
}
@keyframes drop{
0%{
height: 0;
box-shadow: 0 -5px 10px;
}
}
ul{
text-align: center;
margin: 0;
padding: 0;
margin-bottom: 0px;
font-size: 40px;
background-color: orange;
list-style-type: none;
scroll-behavior:
/* height: 75%; */
}
li:nth-child(odd){
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: white;
transition: all 0.3s;
}
li:nth-child(even){
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: orange;
transition: all 0.3s;
}
li:nth-child(odd) span{
position: absolute;
display: block;
right: 0px;
width: 50px;
height: inherit;
background-color: #ff3333;
}
li:nth-child(even) span{
position: absolute;
display: block;
right: 0px;
width: 50px;
height: inherit;
background-color: white;
}
li:hover{
box-shadow: 0px -10px 30px;
height: 80px;
font-size: 60px;
}
form{
/* height: 100px; */
bottom:0;
position: sticky;
/* width:100%; */
background-color: #081327;
color: white;
font-size: 40px;
justify-content: center;
align./-items:center;
}
.error{
display: flex;
opacity: 1;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: black;
color: #ff3333;
z-index: 2;
animation: show 0.7s;
}
.error span{
position: absolute;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
right:0px;
width: 50px;
height: inherit;
background-color: lightblue;
color: #ff3333;
transition:all 0.5s;
}
.error span:hover{
background-color: red;
color: black;
}
li span{
position: absolute;
transition: background-color 0.3s;
right:0px;
cursor: pointer;
}
li span:hover{
background-color: red;
}
form input{
border: 0;
height: 100px;
width:500px;
font-weight: bold;
font-size:40px;
text-align: center;
font-family: Verdana;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
box-shadow: 10px -10px 30px;
}
form button{
border: 0;
height: 100px;
width:300px;
font-size:40px;
margin-bottom:20px;
font-family: Verdana;
font-weight: bold;
background-color: #ff5413;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
box-shadow: 10px -10px 30px;
}
@keyframes show{
/* 20%{
background-color: #1c1c1c;
}
40%{
background-color: black;
}
60%{
background-color: #1c1c1c;
}
80%{
background-color: black;
}
100%{
background-color: #1c1c1c;
} */
0%{
transform-origin: center;
height: 0px;
width: 0px;
font-size: 0px;
}
100%{
height: 50px;
font-size: 40px;
transform-origin: center;
transform: rotateX(360deg);
}
}
#text{
display: flex;
position: absolute;
justify-content: center;
align-items: center;
height: 100%;
position: fixed;
}
#textinfo{
display: flex;
position: relative;
border-radius: 15px;
font-size:40px;
border: solid black 5px;
justify-content: center;
align-items: center;
height: 200px;
text-align: center;
min-width:400px;
overflow: hidden;
width: auto;
background-color: white;
animation:hello 0.5s;
}
@keyframes hello{
0%{
height:0px;
font-size:0px;
}
100%{
height:200px;
font-size:40px;
}
}
#textinfo span{
position: absolute;
top: 10px;
right: 10px;
animation: pop 1.4s;
cursor: pointer;
/* animation-delay: 0.9s; */
}
@keyframes pop{
0%{
transform:translateY(-1000px);
}
50%{
transform:translateY(0px);
transform: rotateY(0deg);
}
100%{
transform: rotateY(1turn);
}
}
/* #description{
height:200px;
animation:flow 5s;
} */
/* @keyframes flow{
0%{
height:0px;
}
100%{
height:200px;
}
} */
</style>
<body ng-app="AngularApp" ng-controller="AngularAppCtrl">
<div>
<ul>
Anime List
<!-- <li ng-repeat="x in anime" ng-click="info(x.anime,x.hero)">
{{x.anime}}<span ng-click="removeAnime($index)">×</span></li> -->
<li ng-repeat="x in anime | orderBy" ng-click="info(x)">{{x}}
<span ng-click="removeAnime(getIndex(x))">×</span></li>
</ul>
<form ng-submit="addAnime()" id="c">
<div class="error" ng-show="existError">Anime Exists<span ng- click="removeErr()">×</span></div>
<center>Enter New Anime<br>
<input type="text" ng-model="newanime" ng- change="checkAnime()" placeholder="Enter Here!" style="color: black;"><button
type="submit">Add Anime</button>
</center>
</form>
</div>
<div id="text" ng-show="infoyes">
<!-- <div id="textinfo">{{name}}<br>{{inform}}</br><span style="color:#ff3333" ng-click="removeInfo()">×</span></div> -->
<div id="textinfo">{{name}}</br><span style="color:#ff3333" ng-click="removeInfo()">×</span></div>
</div>
</body>
<script>
var app = angular.module('AngularApp', []);
app.controller('AngularAppCtrl', function ($scope, $location, $http, $anchorScroll) {
//For fetching data from json
/* $http.get('anime.json').then(function(response){
$scope.anime = response.data.animes;
});*/
$scope.anime = ['Dragon Ball Z', 'One Punch Man', 'Naruto', 'One Piece', 'Yu Yu Hakusho', 'Tokyo Ghoul', 'Pokemon', 'Cowboy Bebop'];
$scope.addAnime = function () {
if (!$scope.newanime) { return; }
if ($scope.anime.indexOf($scope.newanime) == -1) {
/*var split = $scope.newanime.split(':');
$scope.anime.push({'anime': split[0],'hero':split[1]});*/
$scope.anime.push($scope.newanime);
$scope.newanime = "";
$scope.existError = false;
$location.hash('c');
$anchorScroll();
}
else {
$scope.existError = true;
}
};
$scope.removeErr = function () {
$scope.existError = false;
};
$scope.removeAnime = function (x) {
$scope.anime.splice(x, 1);
};
$scope.checkAnime = function () {
if ($scope.anime.indexOf($scope.newanime) == -1) {
$scope.existError = false;
}
else {
$scope.existError = true;
}
};
/*$scope.info = function (x,details) {
$scope.infoyes = true;
$scope.name = x;
$scope.inform = details;
};*/
$scope.info = function (x) {
$scope.infoyes = true;
$scope.name = x;
};
$scope.removeInfo = function () {
$scope.infoyes = false;
};
$scope.getIndex = function (x) {
return $scope.anime.indexOf(x);
}
});
</script>
</html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<title>Angular App</title>
<style>
body{
font-family: Verdana;
font-weight: bold;
display: flex;
justify-content: center;
overflow: auto;
}
div{
width: 100%;
}
li{
position: relative;
animation: drop 0.7s;
cursor: pointer;
}
@keyframes drop{
0%{
height: 0;
box-shadow: 0 -5px 10px;
}
}
ul{
text-align: center;
margin: 0;
padding: 0;
margin-bottom: 0px;
font-size: 40px;
background-color: orange;
list-style-type: none;
scroll-behavior:
/* height: 75%; */
}
li:nth-child(odd){
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: white;
transition: all 0.3s;
}
li:nth-child(even){
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: orange;
transition: all 0.3s;
}
li:nth-child(odd) span{
position: absolute;
display: block;
right: 0px;
width: 50px;
height: inherit;
background-color: #ff3333;
}
li:nth-child(even) span{
position: absolute;
display: block;
right: 0px;
width: 50px;
height: inherit;
background-color: white;
}
li:hover{
box-shadow: 0px -10px 30px;
height: 80px;
font-size: 60px;
}
form{
/* height: 100px; */
bottom:0;
position: sticky;
/* width:100%; */
background-color: #081327;
color: white;
font-size: 40px;
justify-content: center;
align./-items:center;
}
.error{
display: flex;
opacity: 1;
justify-content: center;
align-items: center;
font-size: 40px;
height: 50px;
background-color: black;
color: #ff3333;
z-index: 2;
animation: show 0.7s;
}
.error span{
position: absolute;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
right:0px;
width: 50px;
height: inherit;
background-color: lightblue;
color: #ff3333;
transition:all 0.5s;
}
.error span:hover{
background-color: red;
color: black;
}
li span{
position: absolute;
transition: background-color 0.3s;
right:0px;
cursor: pointer;
}
li span:hover{
background-color: red;
}
form input{
border: 0;
height: 100px;
width:500px;
font-weight: bold;
font-size:40px;
text-align: center;
font-family: Verdana;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
box-shadow: 10px -10px 30px;
}
form button{
border: 0;
height: 100px;
width:300px;
font-size:40px;
margin-bottom:20px;
font-family: Verdana;
font-weight: bold;
background-color: #ff5413;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
box-shadow: 10px -10px 30px;
}
@keyframes show{
/* 20%{
background-color: #1c1c1c;
}
40%{
background-color: black;
}
60%{
background-color: #1c1c1c;
}
80%{
background-color: black;
}
100%{
background-color: #1c1c1c;
} */
0%{
transform-origin: center;
height: 0px;
width: 0px;
font-size: 0px;
}
100%{
height: 50px;
font-size: 40px;
transform-origin: center;
transform: rotateX(360deg);
}
}
#text{
display: flex;
position: absolute;
justify-content: center;
align-items: center;
height: 100%;
position: fixed;
}
#textinfo{
display: flex;
position: relative;
border-radius: 15px;
font-size:40px;
border: solid black 5px;
justify-content: center;
align-items: center;
height: 200px;
text-align: center;
min-width:400px;
overflow: hidden;
width: auto;
background-color: white;
animation:hello 0.5s;
}
@keyframes hello{
0%{
height:0px;
font-size:0px;
}
100%{
height:200px;
font-size:40px;
}
}
#textinfo span{
position: absolute;
top: 10px;
right: 10px;
animation: pop 1.4s;
cursor: pointer;
/* animation-delay: 0.9s; */
}
@keyframes pop{
0%{
transform:translateY(-1000px);
}
50%{
transform:translateY(0px);
transform: rotateY(0deg);
}
100%{
transform: rotateY(1turn);
}
}
/* #description{
height:200px;
animation:flow 5s;
} */
/* @keyframes flow{
0%{
height:0px;
}
100%{
height:200px;
}
} */
</style>
<body ng-app="AngularApp" ng-controller="AngularAppCtrl">
<div>
<ul>
Anime List
<!-- <li ng-repeat="x in anime" ng-click="info(x.anime,x.hero)">
{{x.anime}}<span ng-click="removeAnime($index)">×</span></li> -->
<li ng-repeat="x in anime | orderBy" ng-click="info(x)">{{x}}
<span ng-click="removeAnime(getIndex(x))">×</span></li>
</ul>
<form ng-submit="addAnime()" id="c">
<div class="error" ng-show="existError">Anime Exists<span ng- click="removeErr()">×</span></div>
<center>Enter New Anime<br>
<input type="text" ng-model="newanime" ng- change="checkAnime()" placeholder="Enter Here!" style="color: black;"><button
type="submit">Add Anime</button>
</center>
</form>
</div>
<div id="text" ng-show="infoyes">
<!-- <div id="textinfo">{{name}}<br>{{inform}}</br><span style="color:#ff3333" ng-click="removeInfo()">×</span></div> -->
<div id="textinfo">{{name}}</br><span style="color:#ff3333" ng-click="removeInfo()">×</span></div>
</div>
</body>
<script>
var app = angular.module('AngularApp', []);
app.controller('AngularAppCtrl', function ($scope, $location, $http, $anchorScroll) {
//For fetching data from json
/* $http.get('anime.json').then(function(response){
$scope.anime = response.data.animes;
});*/
$scope.anime = ['Dragon Ball Z', 'One Punch Man', 'Naruto', 'One Piece', 'Yu Yu Hakusho', 'Tokyo Ghoul', 'Pokemon', 'Cowboy Bebop'];
$scope.addAnime = function () {
if (!$scope.newanime) { return; }
if ($scope.anime.indexOf($scope.newanime) == -1) {
/*var split = $scope.newanime.split(':');
$scope.anime.push({'anime': split[0],'hero':split[1]});*/
$scope.anime.push($scope.newanime);
$scope.newanime = "";
$scope.existError = false;
$location.hash('c');
$anchorScroll();
}
else {
$scope.existError = true;
}
};
$scope.removeErr = function () {
$scope.existError = false;
};
$scope.removeAnime = function (x) {
$scope.anime.splice(x, 1);
};
$scope.checkAnime = function () {
if ($scope.anime.indexOf($scope.newanime) == -1) {
$scope.existError = false;
}
else {
$scope.existError = true;
}
};
/*$scope.info = function (x,details) {
$scope.infoyes = true;
$scope.name = x;
$scope.inform = details;
};*/
$scope.info = function (x) {
$scope.infoyes = true;
$scope.name = x;
};
$scope.removeInfo = function () {
$scope.infoyes = false;
};
$scope.getIndex = function (x) {
return $scope.anime.indexOf(x);
}
});
</script>
</html>
最佳答案
您应该考虑使用 Javascript 方法 element.scrollIntoView();
可能是这样的:
$scope.addAnime = function() {
if (!$scope.newanime) {
newanime.scrollIntoView();
return;
}
关于javascript - 如何自动滚动到列表中最后插入的值(非底部)。[[注 :List is Sorted]],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54531771/
如何在不使用垫片的情况下将 View 定位在底部。我知道我可以在 VStack 中放置一个间隔器和我的 View 来实现它,但我不想使用一个间隔器,因为我不希望我的 View 占据所有的垂直空间。使用
我想让文本 float 到现有标签的右下角。 我仍在使用旧学校表(编辑现有代码)。我的代码是这样的:
我有一个包含文本的表格单元格,但我怎样才能使文本齐平到单元格的顶部或底部(上面没有填充)?我试过垂直对齐,但它仍然没有到达顶部“边缘”。 我的代码 3.2325
我想用 javascript 打印一个特殊的页面 div。 function printDiv(divName) { var printContents = document
我需要检查元素是否距离页面底部 x 像素,以动态加载新内容。目前,即使栏位于底部,scrollTop 和高度也不匹配。 jquery 是允许的,虽然基本的 javascript 会更有帮助。 最佳答案
我正在用 pygame 重新制作 flappy bird,但主题是星球大战。我已经完成了游戏的美术和一般格式设置,但现在我需要调整细节。我一直在改变数字,试图让光剑完全到达屏幕的顶部和底部,因为目前有
http://pastehtml.com/view/bfzerlo1m.html 如何将红色框放在橙色 div 底部的 CENTER + 中? 红框的高度和宽度都是动态的,每个框都不同.. (它需要在
我正在研究和测试表格。到目前为止,我成功地使用 following fiddle 将选择框列表中的项目一项一项地向上和向下移动。 . 代码实例(向上移动): function moveUp() { $
在设计 IOS 应用程序时,我可以在页脚放置“后退”按钮功能吗? 最佳答案 我认为指南中没有任何内容禁止这样做,但是您的潜在用户习惯于将后退按钮放在左上角,因此除非您有充分的理由将后退按钮放在底部,并
你可以只在顶部/底部而不是所有(T、B、L、R)设置单元格填充或间距吗? 最佳答案 CSS? td { padding-top: 2px; padding-bottom: 2px; } 关于H
我正在为我的 React 应用程序使用无限滚动,并具有检测我何时恰好位于页面底部的功能: const [isFetching, setIsFetching] = useState(false); //
所以我有一个页面,其中有一个类似聊天的 div,里面充满了文本。它具有固定的高度和宽度(由 css 定义)。 我需要它在每次更新时滚动到底部,这是我到目前为止使用的 JS: $("#div1").an
我遇到了与此处描述的相同的问题:UIWebView doesn't scroll to the bottom of the webpage loaded/created (不幸的是没有人回答) 我有一
我有一个溢出设置为滚动的 div,它本质上是逐行从文件中流式传输数据。我想在流溢出时自动滚动到 div 的底部,但不使用“单击此处滚动到底部”按钮。 我已经知道 scrollTop = scrollH
我正在 Android studio 中构建一个应用程序,但遇到了一些问题。我在 main_activity.xml 中有一个 ImageView
我有一个扩展 Jpanel 的类,里面有一个动画。我有两个操作按钮可以停止和启动它,但是我需要这些按钮出现在 Jpanel 的底部。我已经尝试过: add(go,BOTTOM_ALIGNMENT);
嗨,我正在为ios设备(ipad)开发phonegap / cordova项目。该应用程序通过蓝牙键盘接收输入文本(因为我不想在屏幕上显示键盘)。到目前为止,应用程序可以按预期接收输入。但是关于外观,
我想在底部放置一个页脚。 出于某种原因,它会像这样出现。 在 index.html 中,我有:
我得到了一个带有内联编辑功能的 jqgrid,并且可以添加新行。 目前,新行以“编辑”模式显示在网格顶部。我想要的是将新行添加到网格底部,因为我的“添加新行”按钮位于自定义底部分页器中... 有人知道
在 Swift 3 中,我以编程方式创建了一个(底部)工具栏,其中包含自定义按钮,中间用灵活的垫片分隔自定义按钮,将一个(“上一个”)推到左边缘,另一个(“下一个”)到 View 的右边缘。但我无法显
我是一名优秀的程序员,十分优秀!