html - CSS 如何制作井字游戏发光板?

标签 html css

这是我想要做的愿望设计

enter image description here

我想在井字游戏板上制作发光效果。我已经用 table 来制作板,但我无法做任何事情来制作发光板。我尝试使用盒子阴影,但它会影响所有方向。 这是我的 HTML 代码

    table tr:first-child td{
        border-top:none;
    }
    table tr:last-child td{
        border-bottom:none;
    }
    table tr td:first-child{
        border-left:none;
    }
    table tr td:last-child{
        border-right:none;
    }
.cell{
    width:115px;
    height:115px;
    text-align: center;
    vertical-align: middle;
    color: #fff;
    text-shadow:
      0 0 5px #fff,
      0 0 10px rgb(255, 0, 0),
      0 0 20px rgb(255, 0, 0),
      0 0 40px rgb(255, 102, 0),
      0 0 50px rgb(255, 102, 0),
      0 0 80px rgb(255, 102, 0);
    font-size:90px;
}
   <table>
        <tr>
            <td class="cell" id="0"></td>
            <td class="cell" id="1">X</td>
            <td class="cell-2" id="2">O</td>
        </tr>
        <tr>
            <td class="cell" id="3"></td>
            <td class="cell" id="4"></td>
            <td class="cell" id="5"></td>
        </tr>
        <tr>
            <td class="cell" id="6"></td>
            <td class="cell" id="7"></td>
            <td class="cell" id="8"></td>
        </tr>
    </table>

最佳答案

要制作灯光效果,您需要的是box-shadow,并且您需要设置外部和内部的显示阴影,这样它才会给您光扩散的效果。

检查附件Fiddle .

我们将使用 css psudo 元素 '::before' 和 '::after' 来创建这样的效果。

  • 对于圆形,我们将设置边框半径使其成为圆形,然后使用 '::before' 和 '::after' 设置内部和外部的盒子阴影。

  • 对于十字,我们还使用了“::before”和“::after”,然后将其转换为 45 度 Angular 。使之成为对 Angular 线。当然还有盒子阴影来产生灯光效果。

table
{
  background:black; 
  box-shadow:0px 0px 6px 5px black;
}
table td
{
  padding:10px;
}

.sign
{
  height:40px;
  width:40px; 
  display:inline-block;   
  background-color:transparent;
  position:relative;
}

.sign_o
{    
  box-shadow:0px 0px 5px 3px #09de09;  
  border-radius:20px;  
}
.sign_o::after
{
  content:'';
  height:38px;
  width:38px;  
  border-radius:19px;
  border:1px solid white;
  display:inline-block; 
  position:absolute;
  top:0px;
  left:0px;
}
.sign_o::before
{
  content:'';
  height:40px;
  width:40px;    
  box-shadow:inset 0px 0px 5px 3px #09de09;
  border-radius:40px;
  display:inline-block; 
  position:absolute;
  top:0px;
  left:0px;
}

.sign_x
{
      
}
.sign_x::after
{  
  content:'';
  height:2px;
  width:46px;  
  box-shadow:0px 0px 5px 3px red;    
  display:inline-block;   
  background-color:white;
  position:absolute;
  
   -webkit-transform:translateY(22px)
                     translateX(-4px)
                     rotate(45deg);                     
}

.sign_x::before
{
  content:'';
  height:46px;
  width:2px;  
  box-shadow:0px 0px 5px 3px red;    
  display:inline-block;   
  background-color:white;
  position:absolute;
     -webkit-transform:
          translateY(0px)
          translateX(18px)
          rotate(45deg);
}

table tr:first-child
{
  box-shadow:0px 8px 5px -5px white;  
}

table tr:nth-child(2)
{
  box-shadow:0px -8px 5px -5px white
        , 0px 8px 5px -5px white;
}

table tr:last-child
{
  box-shadow:0px -8px 5px -5px white;  
}

table tr td:first-child
{
  box-shadow:8px 0px 5px -5px white;  
}


table tr td:nth-child(2)
{
  box-shadow:-8px 0px 5px -5px white
        , 8px 0px 5px -5px white;
}

table tr td:last-child
{
  box-shadow:-8px 0px 5px -5px white;  
}
<table>
    <tr>
        <td class="cell" id="0">
          <span class='sign sign_o'></span>
        </td>
        <td class="cell" id="1">          
        </td>
        <td class="cell-2" id="2">
          <span class='sign sign_x'></span>
        </td>
    </tr>
    <tr>
        <td class="cell" id="3"></td>
        <td class="cell" id="4">
          <span class='sign sign_o'></span>
        </td>
        <td class="cell" id="5"></td>
    </tr>
    <tr>
        <td class="cell" id="6">
          <span class='sign sign_x'></span>
        </td>
        <td class="cell" id="7"></td>
        <td class="cell" id="8">
          <span class='sign sign_o'></span>
        </td>
    </tr>
</table>

更新 - 行/列框阴影。 Fiddle

关于html - CSS 如何制作井字游戏发光板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48374884/

相关文章:

css - 将 CSS 中的一长行代码拆分到另一行的正确方法是什么?

javascript - 这个 CSS 菜单是如何创建的?

javascript - 使用 Javascript 或 Jquery 重新加载带有 anchor 的页面

jquery.animate 只工作一次

javascript - 在 slider 上显示/隐藏 div

css - 如何在不覆盖 CSS 的情况下将 XHTML 页面包含在另一个 XHTML 中

javascript - 如何在javascript中仅单击一次后禁用div而不禁用其中元素的点击事件?

html - bg-info 不适用于 bootstrap 中的全身

javascript - Swiper slider 不会为 slider 布局加载多个 View

jquery - 同位素滤光片仅显示滤光画廊图像