2017-05-08 66 views
6

当我键入:如何启用双虚线边框?

<style> 
     .tavit{ 
      width:400px; 
      height:300px; 
      background-color:yellow; 
      border:dashed; /*First I applied - border:dashed double (In order to get a double dashed border - but it didn't work for some reason*/ 
      border-style:double; 
      margin:auto; 
      font-size:medium; 
      text-align:right; 
     } 
     .adom { 
      color: red; 
      font-size: xx-large; 
      text-align: center; 
     } 
    </style> 

没有什么作品。就像它甚至是一个或另一个。我错过了什么? 感谢

+0

你需要共享多一点,其中你在用它吗?有没有覆盖任何其他CSS?... – mxr7350

+0

看这个。有些人已经解决了这个问题。 https://css-tricks.com/forums/topic/double-dotted-border/#post-82796 – ivp

+0

'边框style'属性不起作用这种方式。 double属性意味着双满线,虚线意味着虚线。您可以指定多个值,但会影响元素的不同侧面: https://www.w3schools.com/cssref/pr_border-style.asp – Armin

回答

2

您可以创建一个外部和内部的div并能两者给边界。

div { 
 
    border: 1px dashed black; 
 
} 
 

 
.outer { 
 
    padding: 5px; 
 
}
<div class="outer"> 
 
    <div class="inner">Long long long text</div> 
 
</div>

10

你可以简单地用一个div解决这个问题,你可以使用大纲和边界,然后用outline-offset财产

.test { 
 
    background:white; 
 
    padding:15px; 
 
    border:1px dashed #000; 
 
    outline:1px dashed #000; 
 
    outline-offset:-5px; 
 
}
<div class="test">see this</div>

1

没有border-style as dashed double
border-style:double财产给two bordersolid线,所以你可以使用pseudo selector并宣布边框样式:虚线在两个如下,

.tavit { 
 
    width: 400px; 
 
    height: 300px; 
 
    background-color: yellow; 
 
    border: dashed; 
 
    border-style: dashed; 
 
    margin: auto; 
 
    font-size: medium; 
 
    text-align: right; 
 
    position: relative; 
 
} 
 
    
 
.tavit:before { 
 
    content: ""; 
 
    width: 94%; 
 
    height: 280px; 
 
    border-style: dashed; 
 
    position: absolute; 
 
    left: 2%; 
 
    top: 8px; 
 
}
<div class="tavit"> 
 

 
</div>