简体   繁体   English

左侧和右侧带有图像图案的垂直div

[英]A vertical div with an image pattern on the left and right side

So I am trying to make a div like this 所以我想做一个像这样的div 在此处输入图片说明

But I want it to be vertical because I want the div two kindof have like a paper style look to it: This is the vertical div and I want the random curly edges from above to be on the left and right side of the div 但是我希望它是垂直的,因为我希望div的两种种类都像纸张样式一样:这是垂直div,并且我希望从上方开始的随机卷曲边缘在div的左侧和右侧 在此处输入图片说明 On the second image you see a blue weired border. 在第二张图像上,您看到一个蓝色的怪异边框。 I tried to do it with border-image but this doesn't really seem to work because of the random pattern of the border image I'm trying to use. 我尝试使用border-image进行此操作,但是由于我要使用的border image的随机图案,因此这似乎并没有奏效。

Css I have right now: 我现在有的CSS:

bg-section {
border-image: url(../images/test.png) 120 round;
border-right: 40px solid transparent;
border-left: 40px solid transparent;
width: 70%;
margin: auto;
linear-gradient(rgba(199,194,183,0.2), rgba(199,194,183,0));
}

This is the border I am trying to use: 这是我要使用的边界: 在此处输入图片说明

You can rotate the image using any tool then use it as background and rely on repeat: 您可以使用任何工具旋转图像,然后将其用作背景并依靠重复:

 body { min-height:800vh; margin:0; background: url(https://i.stack.imgur.com/rFPJV.png) right repeat-y, url(https://i.stack.imgur.com/uMYNC.png) left repeat-y, linear-gradient(green,green) center / calc(100% - 138px) 100% no-repeat; } 

With the same image you can use pseudo element and rely on transform to rotate the image. 对于同一图像,您可以使用伪元素并依靠变换来旋转图像。 You can also easily control the width of the borders: 您还可以轻松控制边框的宽度:

 body { min-height:800vh; margin:0; position:relative; background:linear-gradient(green,green) center / calc(100% - 50px) 100% no-repeat } body:before, body:after { content:""; position:absolute; top:0; bottom:0; width:20px; /*Control the width of the border*/ background: url(https://i.stack.imgur.com/rFPJV.png) center/contain repeat-y } body:before { right:10px; } body:after { left:10px; transform:scale(-1,1); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM