0

我的困境是我想要左边的盒子和右边的 iframe 与五个盒子并排,我不确定如何去做。这是我的代码;

<script>
function clock()
{
setInterval(
function(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
var box1 = document.getElementById("box1");
var box2 = document.getElementById("box2");
var box3 = document.getElementById("box3");
var box4 = document.getElementById("box4");
var box5 = document.getElementById("box5");

switch(m % 10)
{
    case 0:
        box1.style.backgroundColor = "#34db00";
        box2.style.backgroundColor = "#ffc000";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 1:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#34db00";
        box3.style.backgroundColor = "#ffc000";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 2:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#34db00";
        box4.style.backgroundColor = "#ffc000";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 3:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#34db00";
        box5.style.backgroundColor = "#ffc000";
        break;
    case 4:
        box1.style.backgroundColor = "#ffc000";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#34db00";
        break;
    case 5:
        box1.style.backgroundColor = "#34db00";
        box2.style.backgroundColor = "#ffc000";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 6:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#34db00";
        box3.style.backgroundColor = "#ffc000";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 7:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#34db00";
        box4.style.backgroundColor = "#ffc000";
        box5.style.backgroundColor = "#0093ff";
        break;
    case 8:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#34db00";
        box5.style.backgroundColor = "#ffc000";
        break;
    case 9:
        box1.style.backgroundColor = "#ffc000";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#34db00";
        break;            
    default:
        box1.style.backgroundColor = "#0093ff";
        box2.style.backgroundColor = "#0093ff";
        box3.style.backgroundColor = "#0093ff";
        box4.style.backgroundColor = "#0093ff";
        box5.style.backgroundColor = "#0093ff";
}
}, 1000);   
}

clock();
</script>


<style media="screen" type="text/css">

div 
{
width:30%; 
height:19.242%; 
background-color:#0093ff;  
border-radius:25px;
}
</style>






<div id="box1"></div>
<div id="box2"></div>
<div id="box3"></div>
<div id="box4"></div>
<div id="box5"></div>



<iframe src="https://www.google.co.uk/" name="iframe1" align="right" width="69%"  height="600"></iframe>

并且根据需要显示为左侧下方的 5 个框,但是 iframe 位于右侧下方,而不是右侧框的一侧。我怎样才能让他们并排?谢谢。

4

0 回答 0