簡體   English   中英

在網頁上水平對齊時鍾

[英]Align clocks horizontally on a webpage

我希望時鍾在我正在設計的網頁上顯示不同的時區。為此,我從名為qlock的網站中嵌入了javascript文件。HTML代碼如下:

<script type="text/javascript">
qlock_city_name="Adelaide";
qlock_gmt_offset=9.5;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
</script>
<script type="text/javascript" src="http://www.qlock.com/live/qlock.js"></script>

<script type="text/javascript"><!--
qlock_city_name="Melbourne";
qlock_gmt_offset=10;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
//--></script>
<script type="text/javascript" src="http://www.qlock.com/live/qlock.js"></script>

這是將阿德萊德和墨爾本的時鍾顯示在另一個下方。 有什么方法可以將它們水平地彼此相鄰顯示嗎?

檢查這個小提琴

用div包裹時鍾,並給它加上浮點數

<div class="left"><script type="text/javascript">
qlock_city_name="Adelaide";
qlock_gmt_offset=9.5;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
</script>
<script type="text/javascript" src="http://www.qlock.com/live/qlock.js"></script>
    </div>
<div class="left">
<script type="text/javascript"><!--
qlock_city_name="Melbourne";
qlock_gmt_offset=10;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
//--></script>
<script type="text/javascript" src="http://www.qlock.com/live/qlock.js"></script>
    </div>

CSS

.left {
    float:left;
}

您可以在時鍾上設置css屬性以向左浮動

#qlock1, #qlock2{
    float: left;
}

在這里演示

PS,您可以為所有時鍾設置一個通用類,而不用擔心CSS中的每個ID

我的方法是將腳本放在一個簡單的表中。

<table style="table-layout:fixed;width:600px;">
  <tr height="30">
    <td width="150"><script type="text/javascript"><!--
qlock_city_name="Melbourne";
qlock_gmt_offset=10;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
//--></script>
<script type="text/javascript" src="qlock.js"></script>
</td>
    <td width="200"><script type="text/javascript">
qlock_city_name="Adelaide";
qlock_gmt_offset=9.5;
qlock_bg_color="#000000";
qlock_text_color="#ffffff";
qlock_dst_week1=1;
qlock_dst_dow1=7;
qlock_dst_month1=10;
qlock_dst_week2=1;
qlock_dst_dow2=7;
qlock_dst_month2=4;
</script>
<script type="text/javascript" src="qlock.js"></script>
</td>
    <td width="250">CSS table layout cell 3</td>
  </tr>
</table>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM