html - 用除数制作 4 个单元格

标签 html css

如何制作最简单盒子的这些除数。我有这个简单的框 html 和 css。 HTML代码是:

<div id="box"></div>

盒子的CSS代码是:

#box{

    width: 350px;
    height: 200px;
    border-radius: 5px; /* IE10+ */
    background-image: -ms-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%); /* Mozilla Firefox */
    background-image: -moz-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%); /* Opera */
    background-image: -o-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%); /* Webkit (Safari/Chrome 10) */
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFFFFF), color-stop(100, #d6d6d6)); /* Webkit (Chrome 11+) */
    background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%); /* W3C Markup */
    background-image: linear-gradient(to bottom, #FFFFFF 0%, #d6d6d6 100%);

}

好的。让我们去除数...我该怎么做?图片链接在这里:

example

谢谢

最佳答案

在顶部叠加几个伪元素可能会起作用:

body {
  background: #c0ffee;
}
#box {
  width: 350px;
  height: 200px;
  margin: 2em auto;
  border-radius: 5px;
  /* IE10+ */
  background-image: -ms-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%);
  /* Mozilla Firefox */
  background-image: -moz-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%);
  /* Opera */
  background-image: -o-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%);
  /* Webkit (Safari/Chrome 10) */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFFFFF), color-stop(100, #d6d6d6));
  /* Webkit (Chrome 11+) */
  background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #d6d6d6 100%);
  /* W3C Markup */
  background-image: linear-gradient(to bottom, #FFFFFF 0%, #d6d6d6 100%);
  position: relative;
}
#box::before,
#box::after {
  content: '';
  position: absolute;
}
#box::before {
  width: 100%;
  top: 50%;
  left: 0;
  margin-top: -3px;
  height: 4px;
  background: linear-gradient(to bottom, white, lightgrey);
  border-radius: 2px;
  z-index: 1;
}
#box::after {
  width: 4px;
  top: 0%;
  left: 50%;
  margin-left: -3px;
  height: 100%;
  background: linear-gradient(to left, white, lightgrey);
  border-radius: 3px;
  z-index: 2;
}
<div id="box"></div>

关于html - 用除数制作 4 个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35991328/

相关文章:

html - 带有图形背景的 Bootstrap 全宽部分

javascript - 如何设置为 100% 和重置为 0% 进度条

jquery - 使用多个 JQuery 脚本

javascript - 不要使用 Jquery 获取适当的 div

html - Bootstrap Input-Group with Spinner 给出奇怪的旋转 D 形

javascript - 在 mouseenter/leave 上用 javascript 显示和隐藏 <ul>

html - 随机化 flex box 顺序

jquery - 使用 Javascript 缩放 svg 路径

html - 为什么我不能在 chrome 中显示这个跨度,但我可以在 FF 中显示?

javascript - Swiper.js 自定义分页名称