您需要将svg元素包装在div(.svg-container)中,该div 绝对位于.sec1要“删除” 的主要区域()内。然后,需要在主区域上应用一个相对位置,以便包装div知道相对于以下位置的位置:
的HTML
<div class="sec1">
<div class="svg-container">
<svg height='100%' width='100%' xmlns='http://www.w3.org/2000/svg'>
<line stroke='#5AB1BB' stroke-width='2' x1='0' x2='10000' y1='0' y2='10000'></line></svg>
</div>
<div class="w3-container">
<div class="maintitlesection">
<div class="title">
William Stinson
</div>
<p>Computers, graphics, photo and video (and lots more).</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
的CSS
.sec1 {
position: relative;
}
.svg-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.maintitlesection {
position: absolute;
width: 300px;
right: 30px;
}
Run Code Online (Sandbox Code Playgroud)