简体   繁体   English

在网页上水平对齐时钟

[英]Align clocks horizontally on a webpage

I want clocks displaying different time zones on a webpage that i am designing.For this,i have embedded the javascript files from a webiste called qlock.The HTML code is as follows: 我希望时钟在我正在设计的网页上显示不同的时区。为此,我从名为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>

What this does is display the clocks of Adelaide and Melbourne one below the other. 这是将阿德莱德和墨尔本的时钟显示在另一个下方。 Is there any way to display them horizontally right next to each other? 有什么方法可以将它们水平地彼此相邻显示吗?

Check this Fiddle 检查这个小提琴

Wrap the clock with div and give the float to it 用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 CSS

.left {
    float:left;
}

you could set a css property on your clocks to float left 您可以在时钟上设置css属性以向左浮动

#qlock1, #qlock2{
    float: left;
}

demo here 在这里演示

PS you could set a common class for all clocks and not worry about every id in your css PS,您可以为所有时钟设置一个通用类,而不用担心CSS中的每个ID

My way would be to place the scripts inside a simple table; 我的方法是将脚本放在一个简单的表中。

<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