- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我一直在尝试构建一个可以用作语音计时器的非常简单的 Javascript/CSS/HTML 页面/应用程序。我的计划是构建一个东西,在演讲者讲话一段时间后,琥珀色的“警告灯”亮起,然后在第二个设定时间后亮起红灯。例如,如果演讲的时长为 10 分钟,琥珀色灯会在 7-8 分钟左右显示警告,鼓励演讲者开始总结,然后红灯会在 10 分钟时亮起让演讲者知道他们已经超过了规定的时间。
无论如何 - 我已经构建了以下内容(我在一天内完成了这项工作,对 CSS/JavaScript 有非常基本的了解,所以我为自己感到骄傲......)。
这行得通(尽管出于示例的目的,我将时间缩短为秒而不是分钟)但我开始超越自己并想知道是否可以使用 CSS 来应用格子/玻璃/钻石类型影响我的形状,使它看起来更像“灯”。例如:Lamp Image
提前致谢,并对任何糟糕的编码礼仪表示歉意 - 我是一个完全的新手。
谢谢!
代码笔在这里:Codepen
function timedText() {
let lbl = document.getElementById('startButton');
let buttonName = "Running";
lbl.innerText = buttonName;
var a = document.getElementById("amberTime");
var amberT = a.options[a.selectedIndex].value;
var r = document.getElementById("redTime");
var redT = r.options[r.selectedIndex].value;
myVar = setTimeout(myTimeout1, amberT * 1000)
myVar2 = setTimeout(myTimeout2, redT * 1000)
}
function myTimeout1() {
//document.getElementById('amberlight').style.background = '#ffbf00';
document.getElementById("amberlight").style.visibility = "visible";
}
function myTimeout2() {
//document.getElementById('redlight').style.background = '#ff0000';
document.getElementById("redlight").style.visibility = "visible";
}
function myStopFunction() {
let lbl = document.getElementById('startButton');
let buttonName = "Start";
lbl.innerText = buttonName;
document.getElementById('amberlight').style.visibility = 'hidden';
document.getElementById('redlight').style.visibility = 'hidden';
clearTimeout(myVar);
clearTimeout(myVar2);
}
.amberlight {
border-radius: 50%;
padding: 0px;
width: 300px;
height: 300px;
margin:auto;
visibility:hidden;
animation: glowing 2500ms infinite;
}
@keyframes glowing {
0% { background-color: #ff7f00; box-shadow: 0 0 3px #ff7f00; }
50% { background-color: #ff9500; box-shadow: 0 0 40px #ff9500; }
100% { background-color: #ff7f00; box-shadow: 0 0 3px #ff7f00; }
}
.redlight {
border-radius: 50%;
padding: 0px;
width: 300px;
height: 300px;
margin:auto;
visibility:hidden;
animation: glowing2 2500ms infinite;
}
@keyframes glowing2 {
0% { background-color: #cc0000; box-shadow: 0 0 3px #cc0000; }
50% { background-color: #ff0000; box-shadow: 0 0 40px #ff0000; }
100% { background-color: #cc0000; box-shadow: 0 0 3px #cc0000; }
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
margin: 0 auto;
}
td {
padding: 20px;
text-align: center;
}
.button1 {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 35px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button2 {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
<table style="width:60%">
<tr>
<td colspan="1">
<div id="amberlight" class="amberlight"></div>
</td>
<td colspan="3">
<div id="redlight" class="redlight"></div>
</td>
</tr>
<tr>
<td width="50%">
<button id="startButton" onclick="timedText()" class="button1">Start</button>
<button onclick="myStopFunction()" class="button2">Stop/Reset</button>
</td>
<td width="20%">
<div>Time for Amber Light</div>
<select id="amberTime">
<option value="5" selected="selected">5 Seconds</option>
<option value="10">10 Seconds</option>
<option value="15">15 Seconds</option>
</select>
</td>
<td width="20%">
<div>Time for Red Light</div>
<select id="redTime">
<option value="5">5 Seconds</option>
<option value="10" selected="selected">10 Seconds</option>
<option value="15">15 Seconds</option>
</select>
</td>
<td width="10%">
<div>Test</div>
<button onclick="myTimeout1()">1</button>
<button onclick="myTimeout2()">2</button>
</td>
</tr>
</table>
最佳答案
如果你想要一个真实的外观,更简单的方法是使用CSS filters在准备好的图像上。
过滤函数:
还有
为了获得更好的效果,只裁剪您想让它发光的部分。
将其他部分切片并叠加,然后使用 position: absolute
您可以使用其他 div 叠加图像,使用绝对定位来组合具有渐变和不透明度的效果,以产生“发光”效果。
您可以使用 CSS transitions或 animations以获得流畅的动画效果。
img {
animation-duration: 5s;
animation-name: anim;
animation-iteration-count: infinite;
-animation-direction: alternate;
animation-timing-function: ease-in;
}
@keyframes anim {
0% {
filter: blur(0px) hue-rotate(0deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
10% {
filter: blur(1px) hue-rotate(20deg) saturate(1) brightness(3) contrast(2);
}
30% {
filter: blur(0px) hue-rotate(0deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
31% {
filter: blur(0px) hue-rotate(-20deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
40% {
filter: blur(1px) hue-rotate(-20deg) saturate(1) brightness(2) contrast(2);
}
60% {
filter: blur(0px) hue-rotate(-20deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
61% {
filter: blur(0px) hue-rotate(90deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
70% {
filter: blur(1px) hue-rotate(90deg) saturate(1) brightness(2) contrast(2);
}
100% {
filter: blur(0px) hue-rotate(90deg) saturate(0.5) brightness(0.9) contrast(1.2);
}
}
<img src="http://www.truck-lite.com/DAMRoot/WebLarge/10002/44276YF.jpg" width="200">
将我的答案与改进的 Gershom 结合起来,您可以存档此效果
body{
background: gray;
}
.blink {
animation-duration: 0.5s;
animation-name: anim;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in;
}
@keyframes anim {
0% {
filter: blur(0px) hue-rotate(-10deg) saturate(0.9) brightness(0.5) contrast(1.5);
}
100% {
filter: blur(2px) hue-rotate(20deg) saturate(1) brightness(1.2) contrast(1.5);
box-shadow:
inset 3px 0px 10px rgba(255, 255, 255, 0.5),
inset 10px 10px 50px rgba(255, 255, 255, 0.2),
inset -10px -10px 50px rgba(0, 0, 0, 0.25),
0px 0px 10px rgba(0, 0, 0, 0.3),
0px 0px 50px 10px rgba(255,180,0,1);
}
}
.light {
position: absolute;
width: 200px;
height: 200px;
left: 50%;
top: 50%;
margin-left: -100px;
margin-top: -100px;
border-radius: 100%;
background-image: linear-gradient(45deg, #ff8000, #ffa040);
background-repeat: repeat;
background-size: 20px 20px;
transform: rotate(45deg);
/* shadows for 3d effect */
box-shadow:
inset 3px 0px 10px rgba(255, 255, 255, 0.5),
inset 10px 10px 50px rgba(255, 255, 255, 0.2),
inset -10px -10px 50px rgba(0, 0, 0, 0.25),
0px 0px 10px rgba(0, 0, 0, 0.3);
}
/* glow */
.light:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
border-radius: 100%;
background:
radial-gradient(ellipse at center, rgba(255, 255, 100, 0.3) 0%, rgba(0, 0, 0, 0) 100%),
radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 10%, rgba(255, 255, 255, 0) 100%);
}
<div class="light blink"></div>
关于javascript - 如何将效果应用于 CSS 形状,使其看起来像一盏逼真的灯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55009536/
#include #include #include using namespace std::chrono; int main(int arc, char* argv[]) { con
我是 opencv 的新手。当我将 sRGB png 提供给它时,我发现以下代码交换了红色和蓝色 channel 。我应该责怪哪个函数,imread 还是 fromarray? 最佳答案 是的,O
我正在使用以下代码,它缩小了每一行,并且由于某种原因整个用户界面也丢失了。我该如何解决?
它是关于以下设置的:Linux 机器、bash、adb、带有 Busybox 的嵌入式 Linux 目标系统。对于目标系统,以下适用: adb shell echo $SHELL /bin/sh ad
当我在 Android Studio 上创建一个空 fragment 时,它会生成以下代码: /** * A simple {@link Fragment} subclass. * Activit
我正在尝试从 Meteor 应用程序的服务器端发布用户的 Facebook 提要: result = Meteor.http.call 'POST', "https://graph.faceb
目前我有两个不同的查询,它们返回完全相同的结果,但是,更改从中过滤结果的参数会使它们以非常不同的方式运行。 搜索 cartography 时的结果 查询 #1: 22 行/~860 毫秒; SELEC
我已经创建了结构: typedef struct { short s; int i; struct Ss { short s; }; } S;
我想在 Java 中打印反斜杠 t。但每当我尝试时,它实际上都将它作为\t 运算符。双反斜杠不起作用。我该怎么做。 最佳答案 例如通过添加另一个反斜杠来转义反斜杠 System.out.println
我想弄清楚为什么 UIActivityViewController 发送一个稍微转换过的字符串来分享给邮件和微信。 这是我的代码: let activityViewController = UIAct
创建标准 SQLite 游标后,我将使用以下方法遍历条目: while (cursor.moveToNext()) { } 所有行都被正确处理。我读过的所有文档都表明您需要发出 moveToFirst
我正在尝试创建一个基本论坛,但在 SQL 中仅打印一行时遇到问题。这是我的 PHP: {$title}"; } } else { print "failed to reach post
我的新 div 元素 ( ) 似乎隐藏在图像后面。我键入的任何内容都显示在图像后面。我想在背景图片之后继续工作。 这是我的代码: DISPLAY
UPD。一行代码解决了问题:.lean() axplanation here 我在 Model.find(...blablabla : [ {"_id":"578763de6e8e0542195ef4
我在 Ubuntu 16.04 中安装了 Tomcat 8.0.45。我使用 let's encrypt 生成的证书启用了 HTTPS 连接器。它就像一个魅力。但是今天Tomcat无法启动HTTPS连
今天,我在一台全新安装了 Windows 7 Ultimate 64 位的新笔记本电脑上安装了 Visual Studio 2010 Professional。我非常习惯于 Visual Studio
根据 Oracle,我应该能够将 .intValue() 和 .compareTo() 之类的方法应用于 double ,但是当我编写 dbl.toString( ) 例如,在 NetBeans 中,
正在为应用程序开发一些拖放功能,虽然可以使用“重影图像”来完成很多事情,将毒品从一个地方转移到另一个地方,但它们看起来总是有点“褪色” - 因此得名鬼影。是否有可能使这些具有与原始颜色相同的深度?谢谢
我是这方面的新手,很抱歉犯了一些愚蠢的错误。快乐学习。每当我使用 URL : localhost:3000/posts/whatever 时,我都会收到无法获取错误。在你问之前,是的,那是在我将内容放
背景 这自然是合法的: let closure: (Int, Int) -> () = { print($0 + $1) } closure(1, 2) // 3 鉴于,自进化提案实现以来 SE-01
我是一名优秀的程序员,十分优秀!