我正在做一个tumblr页面.我有两个不同的html页面背景,我希望DAY背景显示从早上7点到晚上8点,夜晚背景显示从晚上8点到早上7点.
我决定在php中这样做,但是当涉及到php时,我总是新手.我的朋友给我发了一个我可以使用的示例代码.但我不知道该怎么做.你们能帮忙吗?
这是示例代码.
<?php
header('content-type: text/css');
date_default_timezone_set("America/Vancouver");
$now = date('G');
if ($now < 12) {
$bg = '#FFFFFF';
} else {
$bg = '#000000';
}
?>
body {
background: <?php echo $bg; ?>;
}
Run Code Online (Sandbox Code Playgroud) 好吧,我有两个不同的背景.jpgs,我想用它作为背景,取决于它是什么时间.我想要从早上7点到晚上8点的阳光背景和从晚上8点到早上7点的夜晚背景.
我正在处理远程html文件,我将背景和图形存储在与实际html文件不同的服务器上.大多数css都在html文件中,除了包含我分离并移动到外部样式表的背景代码的body部分.我制作了两张单独的样式表,一张是白天bg图像,一张是晚上.这是夜间css样式表上的身体css.
@charset "UTF-8";
/* CSS Document */
body {
background-image: url('http://itsnotch.com/tumblr/images/daytime_bg.jpg') !important;
background-repeat: repeat-x !important;
background-attachment: fixed !important;
background-position: top center !important;
background-color:#b68e59 !important;
margin-top:-5px !important;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:14px !important;
}
Run Code Online (Sandbox Code Playgroud)
我写了一个我觉得可行的javascript代码.但事实并非如此.我把它放在正下方,它仍然无法正常工作.它为什么不起作用?我只是希望能够时间敏感地切换背景.
<script type="text/JavaScript">
<!--
function getStylesheet() {
var currentTime = new Date().getHours();
if (7 <= currentTime&¤tTime < 20) {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/daytime.css' type='text/css'>");
}
else {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/nighttime.css' type='text/css'>");
}
rel='stylesheet' href='night.css' type='text/css'>");
}
}
getStylesheet();
-->
</script>
<noscript><link href="http://itsnotch.com/tumblr/files/daytime.css" rel="stylesheet" type="text/css"></noscript> …Run Code Online (Sandbox Code Playgroud) 我无法在Internet Explorer中获取h1和h2标签显示.我查看了CSS文件,但仍然无法理解为什么它不适用于IE9.
以下是未在IE中显示的标头的CSS代码:
.person h1
{
color: #475261;
font-size: 48px;
font-weight: 400;
letter-spacing: -1px;
margin-left: -60px;
}
.item h2
{
color: #06A;
font-family: Georgia, serif;
font-size: 22px;
font-weight: 400;
letter-spacing: -1px;
}
.item h2 a
{
color: #06A;
text-decoration: none;
}
Run Code Online (Sandbox Code Playgroud)
我几天前写了一个脚本,它会根据一天中的时间切换我页面的css样式表.它似乎工作正常,直到我意识到它经过一次脚本后,它会停止.
例如.当我第一次实现脚本时,它将使用一天的样式表,然后在晚上使用另一个样式表,然后在日落期间使用第三个样式表,最后在晚上使用一次.它会第一次这样做.但是在第4次切换之后,除非我重新实现脚本,否则它不会再次切换.它只停留在切换到脚本底部的样式表上因为我是javascript的新手我不知道它为什么要这样做.
我使用相同的javascript函数来控制图片和其他东西,它们似乎完美无缺.这是代码.
<!--CSS Stylesheet Switch Code--->
<script type="text/JavaScript">
<!--
function getStylesheet() {
var currentTime = new Date().getHours();
if (7 <= currentTime && currentTime < 17) {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/vice.css' type='text/css'>");
}
if (17 <= currentTime && currentTime < 19) {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/evening.css' type='text/css'>");
}
if (19 <= currentTime && currentTime < 21) {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/dusk.css' type='text/css'>");
}
else {
document.write("<link rel='stylesheet' href='http://itsnotch.com/tumblr/files/nighttime.css' type='text/css'>");
}
}
getStylesheet();
-->
</script>
Run Code Online (Sandbox Code Playgroud) 我正在为我的班级编写一个java应用程序.这是一个电话键盘.我快完成了.我只需要显示数字,我就不知道如何更改数字按钮的大小.到目前为止我尝试过的所有内容在编译时都会导致错误.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Graphics;
import javax.swing.JOptionPane;
import javax.swing.JApplet;
import javax.swing.JFrame;
import java.awt.event.*;
public class TelephoneKeypad extends javax.swing.JFrame
{
public TelephoneKeypad()
{
Panel pnlKeyPad = new Panel();
GridLayout gridLayout1 = new GridLayout();
Button btnZero = new Button();
Button btnOne = new Button();
Button btnTwo = new Button();
Button btnThree = new Button();
Button btnFour = new Button();
Button btnFive = new Button();
Button btnSix = new Button();
Button btnSeven = new Button();
Button btnEight = new …Run Code Online (Sandbox Code Playgroud) 我的IDE(TextPad)给了我这个错误:java.lang.ArrayIndexOutOfBoundsException:9
我看了第38行的阵列,看不出问题所在.更改阵列会完全搞砸程序.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
public class TicTacToeGame implements ActionListener {
/*Define Buttons, Variables Etc*/
int[][] winCombinations = new int[][] {
{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, //horizontal wins
{1, 4, 7}, {2, 5, 8}, {3, 6, 9}, //virticle wins
{1, 5, 9}, {3, 5, 7}
};//diagonal wins
JFrame window = new JFrame("Tic-Tac-Toe Game");
JButton btn[] = new JButton[9];
int count = 0;
JLabel lblTitle = new JLabel("Tic Tac Toe …Run Code Online (Sandbox Code Playgroud) 我在相同的网页上有类似的代码,谷歌Chrome加载它就好了.但是这个特殊功能似乎只适用于某些浏览器.我自己找不到任何错误.也许我可以用不同的方式写这个陈述?
<script type="text/JavaScript">
<!--
function changeWebsite() {
var currentTime = new Date().getHours();
if (7 <= currentTime&¤tTime < 17) {
document.write(' <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC01.png" width="200" height="45" alt=""> ');
document.write(' <a href="http://www.itsnotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC02.png" width="200" height="75" border="0" alt="ItsNotch.com"></a> ');
document.write(' <a href="http://www.notchtheguru.com" <img src="http://itsnotch.com/tumblr/images/NotchTheGuru.comVC.png" width="200" height="119" border="0" alt="Tumblr"></a>');
document.write('<a href="http://www.bignotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC04.png" width="200" height="161" border="0" alt="NotchTheGuru.com"></a>');
}
else {
document.write(' <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_01.png" width="200" height="45" alt=""> ');
document.write(' <a href="http://www.itsnotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_02.png" width="200" height="75" border="0" alt="ItsNotch.com"></a> ');
document.write(' <a href="http://www.notchtheguru.com" <img src="http://itsnotch.com/tumblr/images/NotchTheGuru.com.png" width="200" height="119" …Run Code Online (Sandbox Code Playgroud) 我在尝试运行代码时遇到此错误,但无法看到它的错误.
错误:线程"main"中的异常java.lang.NoSuchMethodError:main
import java.awt.*;
import java.awt.event.*;
public class Checkerboard extends Frame implements ActionListener {
Button btnGo = new Button ("Go");
Button btnClear = new Button("Clear");
Label lblStart = new Label("Start");
Label lblStop = new Label("Stop");
Label lblStep = new Label("Step");
TextField txtStart = new TextField(10);
TextField txtStop = new TextField(10);
TextField txtStep = new TextField(10);
Panel pnlCenter = new Panel();
Panel pnlSouth = new Panel();
Panel pnlInput = new Panel();
Panel pnlButton = new Panel();
GridLayout gridColors = new GridLayout(4,4); …Run Code Online (Sandbox Code Playgroud) java ×3
javascript ×3
dynamic-css ×2
awt ×1
css ×1
html ×1
if-statement ×1
php ×1
swing ×1
xhtml ×1