我正在尝试使代码中的按钮滚动显示在中间视频的顶部,但我不太确定我该怎么做? 我试图将按钮作为一个类,例如class =“ button”,然后我尝试使其居中,但它不起作用。 我没有在与按钮相关的css中进行任何操作,一切都在脚本中完成。
这是代码:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" title="Default Styles"/>
<script>
var r_text = new Array();
r_text[0] = "How can we become more self-organised in the next sprint?";
r_text[1] = "How can we improve our productivity, increase our velocity?";
r_text[2] = "How can we get better in Transparency and Visibility of issues and challenges?";
r_text[3] = "How can our PO help us, to focus more on the sprint goal?";
r_text[4] = "How can our SM help us improve our delivery?";
r_text[5] = "How can we be more T-shaped in the next sprint?";
r_text[6] = "How should we celebrate our successes more?";
r_text[7] = "How can we reduce our cycle times?";
r_text[8] = "How can we make our daily scrum more effective?";
r_text[9] = "How can we improve our delivery flow by applying WIP Limit?";
r_text[10] = "How can we improve our collaboration?";
r_text[11] = "How can I help someone else in the next sprint?";
r_text[12] = "How can we improve our Sprint planning event?";
r_text[13] = "How can we demonstrate Scrum Value Courage more?";
r_text[14] = "How can we demonstrate Scrum Value Respect more?";
r_text[15] = "How can we demonstrate Scrum Value Focus more?";
r_text[16] = "How can we demonstrate Scrum Value Commitment more?";
r_text[17] = "How can we demonstrate Scrum Value Openness more?";
r_text[18] = "How can we make Sprint Review more effective?";
r_text[19] = "How can I help PO breakdown user stories better?";
r_text[20] = "How can we improve user story refinement?";
r_text[21] = "How did you overcome a dfficult situation/chalenge?";
r_text[22] = "How can we be more confident about our delivery?";
r_text[23] = "How well do you communicate with others?";
r_text[24] = "How well the team communicates with each other?";
var talk = new Array();
talk[0] = "Talk about issues in our Processes";
talk[1] = "Talk about issues in the Team behaviour";
talk[2] = "Talk about what you want your team to do more";
talk[3] = "Talk about what you want the team to stop doing";
talk[4] = "Talk about what you want the team to start doing";
talk[5] = "Tell us about something that helped you during the sprint to achieve work";
talk[6] = "Talk about something you learnt during the previous sprint";
talk[7] = "Talk about your sprint experience through a sport's game?";
talk[8] = "Talk about your worst time during the sprint?";
talk[9] = "Talk about the biggest success during the sprint?";
talk[10] = "Talk about he major issue you faced during the sprint?";
talk[11] = "Talk about a most recent problem and how did you overcome it?";
talk[12] = "Talk about something that you feared during sprint planning however it was not mentioned at that time?";
talk[13] = "Talk about someone in the team you inspire from and why? Don’t mention the name";
var what = new Array();
what[0] = "What can Scrum Master to improve our Scrum Events?";
what[1] = "What made you feel happy?";
what[2] = "What made you feel unhappy?";
what[3] = "What was your key observations?";
what[4] = "What minor issues that slowed you down";
what[5] = "What can we change to make the biggest leap ahead?";
what[6] = "What did you see happening by someone you think everyone should try?";
what[7] = "What advise would you give to your team members? And why?";
what[8] = "What has been the biggest challenge so far?";
what[9] = "Which problems came up most frequently?";
what[10] = "What has been the most difficult situation in the sprint?";
what[11] = "What obstacles do you anticipate and how you think that can be addressed?";
what[12] = "What can we do to improve our Sprint planning event?";
what[13] = "What would you do differently in the next Sprint?";
what[14] = "What would you like to avoid in the next Sprint?";
what[15] = "What can we do to make our Scrum events more fun?";
what[16] = "What can we do to get full trust of our key stakeholders?";
what[17] = "What support do we need from our PO?";
what[18] = "What support do we need from our SM?";
what[19] = "What support do we need from our Stakeholders? Sponsrs/External…";
what[20] = "Describe the most difficult challenge team faced? What could have been done to avoid/fix it?";
what[21] = "What do you wish you could change in the way of working?";
what[22] = "What support do you need to achieve your sprint goal?";
what[23] = "What areas of your team WOW would you like to improve/change?";
what[24] = "What routinely gets in your way?";
what[25] = "What would you like your PO to do more and why?";
what[26] = "What would you like your SM to do less and why?";
var morefun = new Array();
morefun[0] = "Describe your feeling by naming a Movie. Explain";
morefun[1] = "Describe your feeling by singing a Song. Explain";
morefun[2] = "Describe your feeling by hands/body gestures.";
morefun[3] = "Describe your sprint experience by telling a story?";
morefun[4] = "Who's someone you admire in the team?";
morefun[5] = "What is your favorite quotes?";
morefun[6] = "Who had the most influence on you growing up?";
morefun[7] = "What advise can you give us?";
morefun[8] = "If you could go back in time, what would you like to change? Work or Life";
morefun[9] = "Show your best dance moves?";
morefun[10] = "Draw an emoji to show how you feel about the sprint";
morefun[11] = "How would you have handled Brexit?";
morefun[12] = "If you would become the Prime Minister what would be your top agenda items?";
morefun[13] = "Do an animal impression (please don’t tell)";
morefun[14] = "Do an impression of a Cartoon character (please don’t tell)";
morefun[15] = "If you had a 30 hours a day, how would you use the extra time?";
morefun[16] = "If you could swap your role with another team member, who would it be?";
morefun[17] = "Do a Bhangra dance?";
morefun[18] = "Ask anyone in the team to perform an act? Movie character, cartoon character etc…";
morefun[19] = "Stand on one leg and jump 5 times, or ask your PO to do this act?";
morefun[20] = "Ask your SM or PO to perform a celebration move, or could decide to do it yourself.";
var showshare = new Array();
showshare[0] = "Share your most recent learning experience?";
showshare[1] = "Share any productivity improvement tip with the team?";
showshare[2] = "Share your best moment during the Sprint and why?";
showshare[3] = "if you could change one thing about yourself what would you choose?";
showshare[4] = "If you could eliminate one thing from your daily routine what whould it be?";
showshare[5] = "If you could become an expert in any area instantly, what would it be?";
showshare[6] = "Share a tip to help others improve their ways of working?";
var goingtodo = new Array();
goingtodo[0] = "Do I/we understand the Product Vision? Team and I";
goingtodo[1] = "Do I/we understand the Sprint Goal? Why, Value, Benefits. Team and I";
goingtodo[2] = "Do I/we communicate well within the team? Team and I";
goingtodo[3] = "Do I/we communicate well outside the team? Team and I";
goingtodo[4] = "Do I/we collaborate with team and outside team? Team and I";
goingtodo[5] = "Do I/we openly raise issues and challenges? Team and I";
goingtodo[6] = "Do I/we openly talk about impediments?";
goingtodo[7] = "Do we ask each other for help and support?";
var videos = [{
id: 1,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-1.mp4?autoplay=1",
text: function(){
return r_text[Math.floor(r_text.length*Math.random())];
}
},
{
id: 2,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-2.mp4?autoplay=1",
text: function(){
return what[Math.floor(what.length*Math.random())];
}
},
{
id: 3,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-3.mp4?autoplay=1",
text: function(){
return talk[Math.floor(talk.length*Math.random())];
}
},
{
id: 4,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-4.mp4?autoplay=1",
text: function(){
return morefun[Math.floor(morefun.length*Math.random())];
}
},
{
id: 5,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-5.mp4?autoplay=1",
text: function(){
return showshare[Math.floor(showshare.length*Math.random())];
}
},
{
id: 6,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Red-dice.mp4?autoplay=1",
text: function(){
return goingtodo[Math.floor(goingtodo.length*Math.random())];
}
}
];
var currentTimeout = null;
window.onload = function() {
function rollVideo(numberRand) {
let playerDiv = document.getElementById("random_player");
if (document.querySelector("iframe") !== null) {
document.querySelector("iframe").remove();
}
let player = document.createElement("IFRAME");
let randomVideoUrl = videos[numberRand].url;
player.setAttribute("width", "640");
player.setAttribute("height", "390");
player.setAttribute("src", randomVideoUrl);
playerDiv.appendChild(player);
document.getElementById("text").innerHTML = "";
clearTimeout(currentTimeout);
currentTimeout = setTimeout(() => {
document.getElementById("text").innerHTML = videos[numberRand].text();
}, 3000);
}
document.getElementById("btn-roll").addEventListener("click", startRoll);
function startRoll() {
let currentNumber = Math.floor(Math.random() * videos.length);
rollVideo(currentNumber);
}
};
</script>
</head>
<button id="btn-roll">Roll</button>
<div id="random_player">
<div id="text"></div>
</div>
</html>
答案 0 :(得分:1)
将按钮改为div部分,使用align属性
<div align="center">
<button id="btn-roll">Roll</button>
</div>
答案 1 :(得分:0)
根据我对给定问题的理解,请检查给定解决方案,如果您共享样式,那会很好。
body,html {
width: 100%;
height: 100%;
}
<html>
<head>
<!-- <link rel="stylesheet" type="text/css" href="style.css" title="Default Styles"/> -->
<script>
var r_text = new Array();
r_text[0] = "How can we become more self-organised in the next sprint?";
r_text[1] = "How can we improve our productivity, increase our velocity?";
r_text[2] = "How can we get better in Transparency and Visibility of issues and challenges?";
r_text[3] = "How can our PO help us, to focus more on the sprint goal?";
r_text[4] = "How can our SM help us improve our delivery?";
r_text[5] = "How can we be more T-shaped in the next sprint?";
r_text[6] = "How should we celebrate our successes more?";
r_text[7] = "How can we reduce our cycle times?";
r_text[8] = "How can we make our daily scrum more effective?";
r_text[9] = "How can we improve our delivery flow by applying WIP Limit?";
r_text[10] = "How can we improve our collaboration?";
r_text[11] = "How can I help someone else in the next sprint?";
r_text[12] = "How can we improve our Sprint planning event?";
r_text[13] = "How can we demonstrate Scrum Value Courage more?";
r_text[14] = "How can we demonstrate Scrum Value Respect more?";
r_text[15] = "How can we demonstrate Scrum Value Focus more?";
r_text[16] = "How can we demonstrate Scrum Value Commitment more?";
r_text[17] = "How can we demonstrate Scrum Value Openness more?";
r_text[18] = "How can we make Sprint Review more effective?";
r_text[19] = "How can I help PO breakdown user stories better?";
r_text[20] = "How can we improve user story refinement?";
r_text[21] = "How did you overcome a dfficult situation/chalenge?";
r_text[22] = "How can we be more confident about our delivery?";
r_text[23] = "How well do you communicate with others?";
r_text[24] = "How well the team communicates with each other?";
var talk = new Array();
talk[0] = "Talk about issues in our Processes";
talk[1] = "Talk about issues in the Team behaviour";
talk[2] = "Talk about what you want your team to do more";
talk[3] = "Talk about what you want the team to stop doing";
talk[4] = "Talk about what you want the team to start doing";
talk[5] = "Tell us about something that helped you during the sprint to achieve work";
talk[6] = "Talk about something you learnt during the previous sprint";
talk[7] = "Talk about your sprint experience through a sport's game?";
talk[8] = "Talk about your worst time during the sprint?";
talk[9] = "Talk about the biggest success during the sprint?";
talk[10] = "Talk about he major issue you faced during the sprint?";
talk[11] = "Talk about a most recent problem and how did you overcome it?";
talk[12] = "Talk about something that you feared during sprint planning however it was not mentioned at that time?";
talk[13] = "Talk about someone in the team you inspire from and why? Don’t mention the name";
var what = new Array();
what[0] = "What can Scrum Master to improve our Scrum Events?";
what[1] = "What made you feel happy?";
what[2] = "What made you feel unhappy?";
what[3] = "What was your key observations?";
what[4] = "What minor issues that slowed you down";
what[5] = "What can we change to make the biggest leap ahead?";
what[6] = "What did you see happening by someone you think everyone should try?";
what[7] = "What advise would you give to your team members? And why?";
what[8] = "What has been the biggest challenge so far?";
what[9] = "Which problems came up most frequently?";
what[10] = "What has been the most difficult situation in the sprint?";
what[11] = "What obstacles do you anticipate and how you think that can be addressed?";
what[12] = "What can we do to improve our Sprint planning event?";
what[13] = "What would you do differently in the next Sprint?";
what[14] = "What would you like to avoid in the next Sprint?";
what[15] = "What can we do to make our Scrum events more fun?";
what[16] = "What can we do to get full trust of our key stakeholders?";
what[17] = "What support do we need from our PO?";
what[18] = "What support do we need from our SM?";
what[19] = "What support do we need from our Stakeholders? Sponsrs/External…";
what[20] = "Describe the most difficult challenge team faced? What could have been done to avoid/fix it?";
what[21] = "What do you wish you could change in the way of working?";
what[22] = "What support do you need to achieve your sprint goal?";
what[23] = "What areas of your team WOW would you like to improve/change?";
what[24] = "What routinely gets in your way?";
what[25] = "What would you like your PO to do more and why?";
what[26] = "What would you like your SM to do less and why?";
var morefun = new Array();
morefun[0] = "Describe your feeling by naming a Movie. Explain";
morefun[1] = "Describe your feeling by singing a Song. Explain";
morefun[2] = "Describe your feeling by hands/body gestures.";
morefun[3] = "Describe your sprint experience by telling a story?";
morefun[4] = "Who's someone you admire in the team?";
morefun[5] = "What is your favorite quotes?";
morefun[6] = "Who had the most influence on you growing up?";
morefun[7] = "What advise can you give us?";
morefun[8] = "If you could go back in time, what would you like to change? Work or Life";
morefun[9] = "Show your best dance moves?";
morefun[10] = "Draw an emoji to show how you feel about the sprint";
morefun[11] = "How would you have handled Brexit?";
morefun[12] = "If you would become the Prime Minister what would be your top agenda items?";
morefun[13] = "Do an animal impression (please don’t tell)";
morefun[14] = "Do an impression of a Cartoon character (please don’t tell)";
morefun[15] = "If you had a 30 hours a day, how would you use the extra time?";
morefun[16] = "If you could swap your role with another team member, who would it be?";
morefun[17] = "Do a Bhangra dance?";
morefun[18] = "Ask anyone in the team to perform an act? Movie character, cartoon character etc…";
morefun[19] = "Stand on one leg and jump 5 times, or ask your PO to do this act?";
morefun[20] = "Ask your SM or PO to perform a celebration move, or could decide to do it yourself.";
var showshare = new Array();
showshare[0] = "Share your most recent learning experience?";
showshare[1] = "Share any productivity improvement tip with the team?";
showshare[2] = "Share your best moment during the Sprint and why?";
showshare[3] = "if you could change one thing about yourself what would you choose?";
showshare[4] = "If you could eliminate one thing from your daily routine what whould it be?";
showshare[5] = "If you could become an expert in any area instantly, what would it be?";
showshare[6] = "Share a tip to help others improve their ways of working?";
var goingtodo = new Array();
goingtodo[0] = "Do I/we understand the Product Vision? Team and I";
goingtodo[1] = "Do I/we understand the Sprint Goal? Why, Value, Benefits. Team and I";
goingtodo[2] = "Do I/we communicate well within the team? Team and I";
goingtodo[3] = "Do I/we communicate well outside the team? Team and I";
goingtodo[4] = "Do I/we collaborate with team and outside team? Team and I";
goingtodo[5] = "Do I/we openly raise issues and challenges? Team and I";
goingtodo[6] = "Do I/we openly talk about impediments?";
goingtodo[7] = "Do we ask each other for help and support?";
var videos = [{
id: 1,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-1.mp4?autoplay=1",
text: function(){
return r_text[Math.floor(r_text.length*Math.random())];
}
},
{
id: 2,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-2.mp4?autoplay=1",
text: function(){
return what[Math.floor(what.length*Math.random())];
}
},
{
id: 3,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-3.mp4?autoplay=1",
text: function(){
return talk[Math.floor(talk.length*Math.random())];
}
},
{
id: 4,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-4.mp4?autoplay=1",
text: function(){
return morefun[Math.floor(morefun.length*Math.random())];
}
},
{
id: 5,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Dice-3d-5.mp4?autoplay=1",
text: function(){
return showshare[Math.floor(showshare.length*Math.random())];
}
},
{
id: 6,
url: "http://ebeessolutions.com/wp-content/uploads/2019/10/Red-dice.mp4?autoplay=1",
text: function(){
return goingtodo[Math.floor(goingtodo.length*Math.random())];
}
}
];
var currentTimeout = null;
window.onload = function() {
function rollVideo(numberRand) {
let playerDiv = document.getElementById("random_player");
if (document.querySelector("iframe") !== null) {
document.querySelector("iframe").remove();
}
let player = document.createElement("IFRAME");
let randomVideoUrl = videos[numberRand].url;
player.setAttribute("width", "640");
player.setAttribute("height", "390");
player.setAttribute("src", randomVideoUrl);
playerDiv.appendChild(player);
document.getElementById("text").innerHTML = "";
clearTimeout(currentTimeout);
currentTimeout = setTimeout(() => {
document.getElementById("text").innerHTML = videos[numberRand].text();
}, 3000);
}
document.getElementById("btn-roll").addEventListener("click", startRoll);
function startRoll() {
let currentNumber = Math.floor(Math.random() * videos.length);
rollVideo(currentNumber);
}
};
</script>
</head>
<div style="position: relative;width:100%;height:100%;background: yellow">
<div style="position: absolute;top:50%;left:50%;">
<button id="btn-roll">Roll</button>
</div>
</div>
<div id="random_player">
<div id="text"></div>
</div>
</html>