我正在修改現有的用作iPhone鎖屏的html/javascript包。我希望它看起來像這樣:CSS - 在文本框內定位帶有文本的DIV元素
我決定加入CSS和JavaScript的HTML,所以你可以測試一下馬上:
<html>
<head>
<script language="Javascript">
var now = new Date ();
function getClock ()
{
var hours = now.getHours ();
var minutes = now.getMinutes ();
minutes = (minutes < 10 ? "0" : "") + minutes;
var daypart = (hours < 12) ? "AM" : "PM";
hours = (hours > 12) ? hours - 12 : hours;
hours = (hours == 0) ? 12 : hours;
var clock = hours + ":" + minutes + " " + daypart;
document.getElementById("clock").firstChild.nodeValue = clock;
}
function getCalendar ()
{
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var date = now.getDate()
var month = now.getMonth()
var day = now.getDay()
document.getElementById("date").firstChild.nodeValue = date;
document.getElementById("month").firstChild.nodeValue = months[month].substring(0, 3);
document.getElementById("day").firstChild.nodeValue = days[day];
}
</script>
<style type="text/css">
body { font-family: Calibri; color: #fff; background-color: #000; position: absolute; }
#clock { width: 300px; position: absolute; top: 50%; margin: -.7em 0 0 20px; font-size: 53px; text-shadow: -1px 0 #585858, 0 1px #585858, 1px 0 #585858, 0 -1px #585858;}
#day { font-size: 0.9em; line-height: 35px; }
#month { position: absolute; right: 0px; font-size: 1.91em; line-height: 99px; }
#date { position: absolute; left: -125px; top: 0px; width: 102px; text-align: right; }
</style>
</head>
<body onload="getClock(); setInterval('getClock()', 1000); getCalendar(); setInterval('getCalendar()', 1000)">
<div id="background">
<img src="http://dc463.4shared.com/img/32MahG4Y/s7/0.15818551454745688/Background.jpg" width="320" height="480">
</div>
<div id="clock">
<div id="day">
</div>
<div id="month">
<div id="date">
</div>
</div>
</div>
</div>
</body>
</html>
截至目前,我有兩個未解決的問題:
- 與示例圖像一樣,我希望月份幾乎接觸屏幕的右邊緣,同時保持相同數量的左邊距。這隻能意味着一件事:調整字體的大小以使其適合。這可能必須在Javascript中完成。
- 我現在使用的文本邊框(使用
text-shadow
)相當難看,如果您將我的圖像與示例圖像進行對比,您會發現邊框會使所有區別變得更加明顯!有沒有辦法讓它們更加流暢?
我希望任何人都可以提出一些關於如何解決這些問題的想法。提前致謝!
而你的實際CSS是? –
我不禁嘲笑你想要獲得的WP7外觀。 – Edwin
你呢?我喜歡它,我對舊的滑塊鎖屏感到無聊:P – Daan