我试图让一个随机数生成器生成一个1到9之间的数字串,如果它生成一个8,它应该显示最后8,然后停止生成.
到目前为止,它打印1 2 3 4 5 6 7 8,但它不会生成随机的数字串,因此我需要知道如何使循环实际生成如上所述的随机数,感谢您的帮助!
使用Javascript
// 5. BONUS CHALLENGE: Write a while loop that builds a string of random
integers
// between 0 and 9. Stop building the string when the number 8 comes up.
// Be sure that 8 does print as the last character. The resulting string
// will be a random length.
print('5th Loop:');
text = '';
// Write 5th loop here:
function getRandomNumber( upper ) {
var num = Math.floor(Math.random() * …Run Code Online (Sandbox Code Playgroud) 我正在 Electron 中制作一个应用程序,我有一个无框窗口,我有一些顶部区域,-webkit-app-region: drag但是当我这样做时,它们不会改变。
显然它在这个片段中是不可拖动的,因为它不是一个电子应用程序,但基本上光标在可拖动的元素上不会改变。
编辑:似乎尝试更改任何webkit样式上的光标根本不起作用,因为我也尝试更改滚动条上的光标。有什么解决办法吗?我用谷歌搜索过但没有找到合适的。
#draggable {
-webkit-app-region: drag;
cursor: grab;
height: 40px;
width: 90%;
margin: 0;
background-color: #393939;
color: #000;
position: absolute;
z-index: 2;
top: 0;
border-bottom: 3px solid #202020;
}
#draggable:hover {
cursor: grab;
}Run Code Online (Sandbox Code Playgroud)
<div id="draggable">
<h3 style="margin: 5px 0 0 10px;">Hardware Application</h3>
</div>Run Code Online (Sandbox Code Playgroud)
我有一个应用程序,其中包含用户可以创建的不同列表,并且用户可以编辑名称,但是如果他输入新名称,他应该能够输入 Enter 并向下移动多行。
我想让可编辑区域只有一行。我添加了最大高度并隐藏了溢出,但这实际上只隐藏了您键入的其他内容,并且我只希望保留一行。
代码:
h3 {
height: 25px;
max-height: 25px;
overflow: hidden;
}Run Code Online (Sandbox Code Playgroud)
<h3 contenteditable="true">To Do List</h3>
<section id="pageOne" contenteditable="true">
<li style="color: #393939;"></li>
</section>Run Code Online (Sandbox Code Playgroud)
图片:
我看过Electron关于'无框窗口'的文档,但我似乎无法按下自己的工作来关闭应用程序......
任何帮助,将不胜感激!谢谢!
const electron = require('electron');
const url = require('url');
const path = require('path');
const {app, BrowserWindow} = electron;
let mainWindow;
// Listen for app to be ready
app.on('ready', function() {
// create new window
mainWindow = new BrowserWindow({width: 800, height: 600, frame: false});
// Load html into window
mainWindow.loadURL(url.format({
pathname:path.join(__dirname,'main.html'),
protocol: 'file:',
slashes: true
}));
const closeApp = document.getElementById('closeApp');
closeApp.addEventListener('click', () => {
app.quit();
});
});Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, …Run Code Online (Sandbox Code Playgroud)我希望能够为颜色名称设置颜色,因此如果用户输入字符串"green",颜色将是特殊的绿色,如#34ff8b.
我已经尝试使用变量并将颜色设置为字符串'green',但这不是有效的js.
期望的结果: 用户输入颜色名称"绿色",javascript使用js代码中的特殊颜色集.
const myButton = document.getElementById('myButton');
const myHeading = document.getElementById('myHeading');
const myTextInput = document.getElementById('myTextInput');
myButton.addEventListener('click', () => {
myHeading.style.color = myTextInput.value;
} );Run Code Online (Sandbox Code Playgroud)
@import 'https://fonts.googleapis.com/css?family=Lato:400,700';
body {
color: #484848;
font-family: 'Lato', sans-serif;
padding: .45em 2.65em 3em;
line-height: 1.5;
}
h1 {
margin-bottom: 0;
}
h1 + p {
font-size: 1.08em;
color: #637a91;
margin-top: .5em;
margin-bottom: 2.65em;
padding-bottom: 1.325em;
border-bottom: 1px dotted;
}
ul {
padding-left: 0;
list-style: none;
}
li {
padding: .45em .5em;
margin-bottom: .35em;
display: flex; …Run Code Online (Sandbox Code Playgroud)