How to make pipes with borders in CSS


Rajish Frisky

Maybe you are a little confused from the title above, but as the title says, I want to use CSS for this pipeline design , I think I can use CSS to achieve it, borderbut how do I add the circular bullet like in the image below?

blue pipe i want to make

To simplify things, my layout looks like this:

  1. First row : image 1 and text

  2. Second line : text and image 2

  3. Third row : image 3 and text

  4. Fourth row : picture 4

So here are some questions I want to ask :

  1. Can I use borders for this kind of line?

  2. How can I make the line stop in the middle like before the Image 4?

  3. How can I make the bullet in the middle of the line that will match the line even when we check it in some device (exclude the mobile view around 576px)?

Can someone help me with this problem? for the first question, I think we can use

1. First Row :
border-right: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-right-radius : 10px;

2. second Row :
border-left: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-left-radius : 10px;

3. Third Row :
border-right: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-right-radius : 10px;

4. Fourth Row : 
border-left: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-left-radius : 10px;
width: 50% (?)

Edit 1 for question one currently I make this CSS code like this:

#first-row-left{
    border-left: solid 3px blue;
    border-bottom: solid 3px blue;
    border-bottom-left-radius: 20px
}

#first-row-right{
    border-bottom: solid 3px blue;
}

#second-row-left{
    border-bottom: solid 3px blue;

}

#second-row-right{
    border-right: solid 3px blue;
    border-bottom: solid 3px blue;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px
}

#third-row-left{
    border-left: solid 3px blue;
    border-bottom: solid 3px blue;
    border-bottom-left-radius: 20px;
    border-top-left-radius: 20px

}


and it looks like this

This is the current progress when I use the border

As you can see there is slight miss in before the pipeline change the row like from first to second row

Edit 2 I already make a fiddle for this, you can try it in here:

Click here to see the fiddle

Edit 3 Based on @Alexwc_ , I tried to change his code into CSS intead of SCSS, but it seems I miss something in here

SCSS from @Alexwc_ after I convert it to CSS:

this is the fiddle I made : Check in here

alexwc_

Here's one method. Perhaps not the cleanest, and it hasn't been adapted for mobile.

Here is a pen of the work using SCSS.

Here is a pen of the work using CSS. (Please note that I converted SCSS to CSS using this tool)

CAVEATS:

  1. this was not put into a SO snippet because (for whatever reason) it doesn't display correctly.
  2. I've tested only on Mac OS Chrome/Chrome Canary/FF/FFDE/Safari
  3. On the CodePen I used SCSS
  4. My CSS/SCSS/variables may cause some snickering as I'm no pro at it, and it feels a little hacky... but perhaps other edge-ish cases may cause the same feeling.
  5. I did not see that you had posted your own markup while I was writing this out. Apologies for that.
  6. Bullets can be edited to your liking, I don't think bullet style is really an issue.

CSS:

:root {
    --width: 5px;
    --border-radius: calc(var(--width) * 2);
    --button-width: 30px;
    --button-left-pos: -12.5px;
}

.row {
    margin: 0 20px;
}

img {
    border-radius: 10px;
}

.one, .two, .three, .four {
    position: relative;
}
.one::before, .one::after, .two::before, .two::after, .three::before, .three::after, .four::before, .four::after {
    position: absolute;
    top: var(--button-width);
    left: var(--button-left-pos);
    content: "";
    height: 30px;
    width: 30px;
    background: black;
    border-radius: 100px;
}
.one::after, .two::after, .three::after, .four::after {
    width: calc( var(--button-width) / 2 );
    height: calc( var(--button-width) / 2 );
    background: red;
    top: calc(var(--button-width) + var(--button-width) / 4 );
    left: -5px;
}

.two::before, .two::after {
    right: var(--button-left-pos);
    left: initial;
}
.two::after {
    right: -5px;
}

.one::after {
    width: calc( var(--button-width) / 2 );
    height: calc( var(--button-width) / 2 );
    background: red;
    top: calc(var(--button-width) + var(--button-width) / 4 );
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "left right";
    position: relative;
}
.row:last-child {
    grid-template-areas: "border ..." "full full";
}
.row .left, .row .right {
    padding: var(--button-width);
}

.one .left {
    padding-top: 0;
    border-left: var(--width) solid;
    border-bottom: var(--width) solid;
    border-bottom-left-radius: var(--width);
}

.two {
    top: calc(var(--width) * -1);
}
.two .right {
    border-right: var(--width) solid;
    border-top: var(--width) solid;
    border-top-right-radius: var(--width);
    border-bottom-right-radius: var(--width);
    border-bottom: var(--width) solid;
}

.three {
    top: calc(var(--width) * -2);
}
.three .left {
    border-left: var(--width) solid;
    border-top: var(--width) solid;
    border-top-left-radius: var(--width);
    border-bottom-left-radius: var(--width);
}

.four {
    top: calc(var(--width) * -3);
}
.four::before, .four::after {
    top: 85px;
}
.four::before {
    left: calc(50% - 17.5px);
}
.four::after {
    top: 92.5px;
    left: calc(50% - 10.5px);
}
.four .border {
    height: 200px;
    display: block;
    border-right: var(--width) solid;
    border-top-right-radius: var(--width);
    position: relative;
}
.four .border::before {
    content: "";
    position: absolute;
    height: var(--width);
    background: black;
    top: 0;
    width: calc(100% + var(--width));
    transform: rotate(180deg);
    border-bottom-left-radius: var(--width);
    border-top-right-radius: var(--width);
}

.border {
    grid-area: border;
}

.full-width {
    grid-area: full;
    justify-self: center;
}

.left {
    grid-area: left;
}

.right {
    grid-area: right;
}

HTML:

<div class="row one">
    <div class="left">
      <img src="https://via.placeholder.com/450x250" alt="">

    </div>
    <div class="right">
      <h1>Heading</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
  </div>
  <!-- one -->
  <div class="row two">
    <div class="left">
      <h1>Heading</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

    </div>
    <div class="right">
      <img src="https://via.placeholder.com/450x250" alt="">
    </div>
  </div>
  <!-- two -->
  <div class="row three">
    <div class="left">

      <img src="https://via.placeholder.com/450x250" alt="">

    </div>
    <div class="right">
      <h1>Heading</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
  </div>
  <!-- three -->
  <div class="row four">
    <div class="border border-top"></div>
    <div class="full-width">
      <img src="https://via.placeholder.com/900x500" alt=""></div>
  </div>
  <!-- four -->

Related


How to make pipes with borders in CSS

Rajish Frisky Maybe you are a little confused from the title above, but as the title says, I want to use CSS for this pipeline design , I think I can use CSS to achieve it, borderbut how do I add the circular bullet like in the image below? To simplify things,

How to make pipes with borders in CSS

Rajish Frisky Maybe you are a little confused from the title above, but as the title says, I want to use CSS for this pipeline design , I think I can use CSS to achieve it, borderbut how do I add the circular bullet like in the image below? To simplify things,

How to make pipes with borders in CSS

Rajish Frisky Maybe you are a little confused from the title above, but as the title says, I want to use CSS for this pipeline design , I think I can use CSS to achieve it, borderbut how do I add the circular bullet like in the image below? To simplify things,

How to make CSS borders on images?

Biggest Dredoff How can I crop an image (600х450) and create a border on it using CSS? Enter is it possible? What's better to use? Create some wrapper elements with border-radius? Andy Furniss I think this is the best way to use CSS: CSS: img { width:400px

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make CSS borders on images?

Biggest Dredoff How can I crop an image (600х450) and create a border on it using CSS? Enter is it possible? What's better to use? Create some wrapper elements with border-radius? Andy Furniss I think this is the best way to use CSS: CSS: img { width:400px

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make shapes with CSS with borders?

surrender thakran I'm looking for a way to make various geometric shapes using only HTML/CSS. I found the answer here , but it doesn't allow me to add a border to the shape. For example, I can use #triangle-down { width: 0; height: 0; border-left: 50px solid t

How to make shapes with CSS with borders?

surrender thakran I'm looking for a way to make various geometric shapes using only HTML/CSS. I found the answer here , but it doesn't allow me to add a border to the shape. For example, I can use #triangle-down { width: 0; height: 0; border-left: 50px solid t

How to make CSS borders on images?

Biggest Dredoff How can I crop an image (600х450) and create a border on it using CSS? Enter is it possible? What's better to use? Create some wrapper elements with border-radius? Andy Furniss I think this is the best way to use CSS: CSS: img { width:400px

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make CSS borders on images?

Biggest Dredoff How can I crop an image (600х450) and create a border on it using CSS? Enter is it possible? What's better to use? Create some wrapper elements with border-radius? Andy Furniss I think this is the best way to use CSS: CSS: img { width:400px

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make irregular CSS borders

Gibson I am trying to do this with CSS: It's easy to use a white background, but what if it has a background image? This is what I mean: I actually absolutely place the div inside another: <div class="main-div"> <div class="main-div-overlay-text"> SOME T

How to make CSS borders appear on radio buttons

Dennis When the radio button is clicked, I want to display a border around the image next to the radio button. Currently, my knowledge of CSS selectors is insufficient and I am not getting the expected results. My expectation is that when I click the radio but

How to make CSS shaped buttons/borders?

Frasta Po Please, can you give me some tips on how to make shape buttons/menu navigation? It should look like this: I tried something with borders, but only when div. Here is the code I have tried: .border-right { font-size: 0px; line-height: 0%; width: 0px;

How to make CSS borders appear on radio buttons

Dennis When the radio button is clicked, I want to display a border around the image next to the radio button. Currently, my knowledge of CSS selectors is insufficient and I am not getting the expected results. My expectation is that when I click the radio but

How to make a resizable heart shape in CSS with borders

tom I want to make a heart shape that the user can resize to any width and height with a border of 1 px. I tried a heart shape made with pure CSS : https://stackoverflow.com/a/17386187/1404447 I tried using a font like this : https://www.w3schools.com/charsets

How to make pipes unequal?

Brandon This has come up in multiple instances, and I don't know if this current instance generalizes to many of the cases I have in mind, but I hope the answer sheds some light. The simplest version is when doing data processing and want to evaluate the pipel

How to make pipes unequal?

Brandon This has come up in multiple instances, and I don't know if this current instance generalizes to many of the cases I have in mind, but I hope the answer sheds some light. The simplest version is when doing data processing and want to evaluate the pipel

How to make pipes unequal?

Brandon This has come up in multiple instances, and I don't know if this current instance generalizes to many of the cases I have in mind, but I hope the answer sheds some light. The simplest version is when doing data processing and want to evaluate the pipel