How to slant dashed border in CSS?

独自空忆成欢 提交于 2021-02-08 23:37:18

问题


I am trying to design an envelope using CSS for a Mail App. My client wants dashed borders in this manner

How can I achieve that effect with CSS borders?


回答1:


You may have to play with the colors a little.

.enveloppe {
	padding: 1em;
	border: 16px solid transparent;
	border-image: 16 repeating-linear-gradient(45deg, red 0, red 1em, transparent 0, transparent 2em,
	              #b67 0, #b67 3em, transparent 0, transparent 4em);
	
	max-width: 20em;
}
<div class="enveloppe">Lorem Ipsum</div>



回答2:


If you want to change the position remove the margin of container class.

*:before,
*:after { box-sizing: border-box; }

html,
body {
  overflow: hidden; 
  padding: 0;
  margin: 0;
}

.container {
  width: 300px;
  height: 200px;
  margin:0 auto;
  background-image: repeating-linear-gradient(135deg, #F29B91 0px, #F09290 30px,  transparent 30px, transparent 50px, #83B3DB 50px, #84ADCB 80px, transparent     80px, transparent 100px);
  padding: 12px;
}

.container .inner {
  background: white;
  width: 100%;
  height: 100%;
}
<div class="container">
  <div class="inner">envelope design</div>
 </div>


来源:https://stackoverflow.com/questions/45207075/how-to-slant-dashed-border-in-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!