I tried to remove the intersection of the base of the semicircle and the line by using clip-path in .line, but it did not work. Is this the correct method or is there another way?
I tried to remove the intersection of the base of the semicircle and the line by using clip-path
in .line
, but it did not work. Is this the correct method or is there another way?
How can we solve this problem? How can we remove the part mentioned in the image?
body {
margin: 0vh 0vw;
}
.header {
position: relative;
width: 100%;
height: 12vh;
background-color: #004d40;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
top: 0;
}
.line {
position: absolute;
left: 0;
top: calc(50%);
width: 100%;
height: 0.25vh;
background-color: white;
z-index: 1;
}
svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 0%);
z-index: 2;
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SVG Header with Half Circle</title>
<div class="header">
<div class="line"></div>
<svg width="10vw" height="5vh" viewBox="0 0 100 50" preserveAspectRatio="xMidYMin meet" xmlns="http://www.w3.org/2000/svg">
<path d="M0,0 A50,50 0 0,0 100,0" fill="none" stroke="white" stroke-width="3"/>
</svg>
</div>
2
Answers
Why not use an SVG containing a filled circle? That should mask the line underneath.
Draw the line and the half circle in one go. The SVG gets a very wide
viewBox="0 0 10000 120"
, but withpreserveAspectRatio="xMidYMid slice"
only the middle part is shown, always filling the height of the header, and cutting off the superfluous length at the sides.Now you draw a long horizontal line from the left side to the middle of the viewbox minus the radius of the half circle:
add the half circle (with a relative comand, the end of the half circle can be written as "100 to the right")
and continue the horizontal line to the right side