Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 合并实线和虚线边框_Html_Css - Fatal编程技术网

Html 合并实线和虚线边框

Html 合并实线和虚线边框,html,css,Html,Css,我想按如下方式设置块元素的边框: 也就是说,我想设置黄色实体边框和位于黄色实体上方的黑色虚线边框。如何操作?给元素一个黄色边框,然后使用伪元素创建虚线边框: div{ 位置:相对位置; 边框底部:1px纯黄色; } 部门:之后{ 内容:''; 位置:绝对位置; 左:0; 右:0; 最高:100%; 边框底部:1px虚线#666; } 这里有一个问题:您可以使用框阴影,因为您可以声明任意数量的阴影。然后为中心虚线使用边框。 这是一把小提琴 您也可以使用border+outline测试以下内容:

我想按如下方式设置块元素的边框:


也就是说,我想设置黄色实体边框和位于黄色实体上方的黑色虚线边框。如何操作?

给元素一个黄色边框,然后使用伪元素创建虚线边框:

div{
位置:相对位置;
边框底部:1px纯黄色;
}
部门:之后{
内容:'';
位置:绝对位置;
左:0;
右:0;
最高:100%;
边框底部:1px虚线#666;
}

这里有一个问题:

您可以使用框阴影,因为您可以声明任意数量的阴影。然后为中心虚线使用边框。 这是一把小提琴


您也可以使用
border
+
outline
测试以下内容:

div {
  margin:5em;
  padding:2em;
  outline:dashed 10px;/* same size as border */
  border:solid yellow 10px ;/* same size as outline */
  outline-offset:-10px;/* negative value as opposite size of border/outline */
}

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 使用
框阴影的另一种方法是:

    div {
      margin:5em;
      padding:2em;
      border:dashed 10px;
      background:yellow;
      box-shadow:inset 0 0 0 2000px white;/* this gives a white background , you may use multiple shadow and resize them in order to
 hide background color that will remain seen behind border dashed, double or dotted*/
}

不太清楚-您正在做的是创建两个纯黄色边框,并在它们之间创建一个黑色虚线。@BoltClock oops,您是对的。我想说的另一种方法是使用类似于上面答案的伪元素。如果边框需要包含整个元素,而不是只包含元素的一条边,则需要将所有偏移量更改为
-1px
(对于所有左上右下)和(当然)用
边框
代替
边框底部
@BoltClock-当然。主要是展示OP的要求。一如既往,根据需要进行调整。不用担心,我的评论更多的是为了增加你对OP的回答,而不是针对你或说“你应该改变你的答案!”:)作为记录。不幸的是,这在IE中不起作用。甚至IE11:(哦,是的,IE11:)也不起作用,所以框阴影+背景+边框将是一个平均选项,它只允许背景颜色,如白色:边框:虚线10px;背景:黄色;盒影:插入0 2000px白色;
    div {
      margin:5em;
      padding:2em;
      border:dashed 10px;
      background:yellow;
      box-shadow:inset 0 0 0 2000px white;/* this gives a white background , you may use multiple shadow and resize them in order to
 hide background color that will remain seen behind border dashed, double or dotted*/
}