答案 0 :(得分:2)
您可以使用绝对定位的具有负z-index的伪元素。
.container {
position: relative;
padding: 30px;
}
.container::before {
display: block;
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
right: 70%;
left: 0;
border: 5px solid #E7E7E9;
content: '';
}
<div class="container">
<h2>The Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ut lectus non risus tincidunt lacinia nec ut nunc. Nam viverra ipsum vitae purus tempor, ut maximus lorem semper. Maecenas efficitur feugiat sem, et egestas ex tincidunt eu. Maecenas eu tempor justo. Duis non tempus nunc. Curabitur euismod non lectus non tempor. Cras non risus vel nisl luctus efficitur. Morbi consectetur ante vel ullamcorper semper. Ut interdum risus non velit dignissim aliquet. Ut porta rutrum efficitur. Quisque suscipit est nec tempor vestibulum. Vivamus vel dui at risus auctor ultricies a sed justo.</p>
</div>
答案 1 :(得分:1)
要设计此效果,您可以使用虚拟绝对div来创建背景边框。
* {
box-sizing: border-box;
border: 0px;
padding: 0px;
margin: 0px;
}
.container {
position: relative;
width: 100%;
height: 500px;
background: #f9f9f9;
z-index: 0;
}
.fake-border {
position: absolute;
width: 40%;
height: 90%;
margin: 2.5%;
z-index: -1;
border: 5px solid #bdbdbd;
}
.content {
position: absolute;
top: 50%;
transform: translateY(-50%);
padding-left: 100px;
}
&#13;
<html>
<head>
</head>
<body>
<div class="container">
<div class="fake-border">
</div>
<div class="content">
<h2>Header</h2>
<br><br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
</div>
</div>
</body>
</html>
&#13;