繁体   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