<!DOCTYPE html>
<html>
    <head>
        <title>Simple HTML Game: Hover and Change Color</title>
        <style>
            body {
                display: flex;
                flex-direction: column;
            }
<pre><code>        #game {
            display: flex;
            flex-direction: row;
            width: 500px;
            height: 500px;
            border: solid 1px black; 
        }

        #game &gt; div {
            flex: 1 1 auto;
        }

        .block {
            width: 100%;
            height: 100%;
            background-color: blue;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id='game'&gt;
        &lt;div class='block' onmouseover='this.style.backgroundColor='red';' onmouseout='this.style.backgroundColor='blue';'&gt;&lt;/div&gt;
        &lt;div class='block' onmouseover='this.style.backgroundColor='red';' onmouseout='this.style.backgroundColor='blue';'&gt;&lt;/div&gt;
        &lt;div class='block' onmouseover='this.style.backgroundColor='red';' onmouseout='this.style.backgroundColor='blue';'&gt;&lt;/div&gt;
        &lt;div class='block' onmouseover='this.style.backgroundColor='red';' onmouseout='this.style.backgroundColor='blue';'&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
</code></pre>
</html>
Simple HTML Game: Hover and Change Color

原文地址: https://www.cveoy.top/t/topic/lniW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录