<style> .app { width: max-content; /* fit-content */ min-width: 331px; height: 92px; padding: 0 80px 0 50px; box-sizing: border-box; border-image-source: url('https://lee-1255983702.cos.ap-guangzhou.myqcloud.com/16493477783361.png'); /* 思路1:传统九宫格,上下左右都切,就是中心区域无限延伸 */ /* border-image-slice: 29 154 20 154 fill; */ /* border-image-width: 29px 154px 20px 154px; */ /* 思路2:只切左右,不切上下 */ border-image-slice: 0 154 0 154 fill; border-image-width: 0 154px 0 154px; border-image-repeat: repeat; } .content { /* 为了使用 max-content/fix-content 内容区域最好不要使用绝对定位失去块特征、失去宽度 */ position: relative; text-align: center; top: 40px; } </style> <body> <div class="app"> <div class="content">Lorem ipsum dolor sit amet</div> </div> </body>
<style> .app { width: 456px; min-height: 320px; box-sizing: border-box; border-image-source: url('https://lee-1255983702.cos.ap-guangzhou.myqcloud.com/1649347819653bcard.png'); /* 只切上下两个区域 */ border-image-slice: 40 0 40 0 fill; border-image-width: 40px 0 40px 0px; border-image-repeat: repeat; } </style> <body> <div class="app"></div> </body>
<style> .app { width: 456px; min-height: 393px; box-sizing: border-box; border-image-source: url('https://lee-1255983702.cos.ap-guangzhou.myqcloud.com/1649347861622rcard.png'); /* 只切上下两个区域 */ border-image-slice: 40 0 40 0 fill; border-image-width: 40px 0 40px 0; border-image-repeat: repeat; } </style> <body> <div class="app"></div> </body>