0

I have the following snippet :

.container{
    margin-left: 6%;
    margin-right: 6%;
}

.wrapper{
    flex-grow: 1;
    border-left: 2px solid gray;
    border-right: 2px solid gray;
    border-bottom: 2px solid gray;
}

.svg_position{
    background: blue; 
    width: 150px; 
    height: auto; 
    position: absolute; 
    right: 0;
}

.row{
    display: flex;
}

.col {
    flex: 1;
    padding: 1em;
    display:flex;
    flex-direction:column;
}

div.box_header{
    background-color: gray;
    color: white;
    display: flex;
}

@media (max-width: 991px) {
    .row{
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    .col{
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        margin-right: 0;
    }
}
<div class="container">
    <div class="row">
        <div class="col">
            <div class="box_header">
                <p>COL 1</p>
            </div>
            <div class="wrapper">
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
        <div class="col">
            <div class="box_header">
                <p>COL 2</p>
            </div>
            <div class="wrapper">
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
        <div style="background: red;" class="col">
            <div class="box_header">
                <p>COL 3</p>
            </div>
            <div style="background: green" class="wrapper">
                <div class="svg_position">                 
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142.753 58.5">
                        <path d="M142.753,35l-49,23.5v-47Z" fill="#811818" />
                        <path d="M142.753,35H.065l23.59-17.476L0,0H142.753Z" fill="#b51c1c" />
                    </svg>
                </div>
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
    </div>
</div>

I'm trying to glue the svg into the right border whatever the size of the box is.

Expected result :

Result

executable
  • 3,365
  • 6
  • 24
  • 52

3 Answers3

2

Just add:

.wrapper {
   flex-grow: 1;
   border-left: 2px solid gray;
   border-right: 2px solid gray;
   border-bottom: 2px solid gray;
   position: relative;
}

.svg_position {
    width: 150px;
    height: auto;
    position: absolute;
    right: -35px;
};
Dmitry Sobolevsky
  • 1,171
  • 6
  • 12
1

You were almost there. There was only the position: relative rule missing on the .wrapper element:

.container {
  margin-left: 6%;
  margin-right: 6%;
}

.wrapper {
  position: relative;
  flex-grow: 1;
  border-left: 2px solid gray;
  border-right: 2px solid gray;
  border-bottom: 2px solid gray;
}

.svg_position {
  background: blue;
  width: 150px;
  height: auto;
  position: absolute;
  right: -50px;     /* <-- Play with the right position to have the required effect */
  top: 0;
}

.row {
  display: flex;
}

.col {
  flex: 1;
  padding: 1em;
  display: flex;
  flex-direction: column;
}

div.box_header {
  background-color: gray;
  color: white;
  display: flex;
}

@media (max-width: 991px) {
  .row {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
  }

  .col {
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    margin-right: 0;
  }
}
<div class="container">
  <div class="row">
    <div class="col">
      <div class="box_header">
        <p>COL 1</p>
      </div>
      <div class="wrapper">
        <ul>
          <li>TEXT</li>
          <li>TEXT</li>
          <li>TEXT</li>
        </ul>
      </div>
    </div>
    <div class="col">
      <div class="box_header">
        <p>COL 2</p>
      </div>
      <div class="wrapper">
        <ul>
          <li>TEXT</li>
          <li>TEXT</li>
        </ul>
      </div>
    </div>
    <div style="background: red;" class="col">
      <div class="box_header">
        <p>COL 3</p>
      </div>
      <div style="background: green" class="wrapper">
        <div class="svg_position">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142.753 58.5">
            <path d="M142.753,35l-49,23.5v-47Z" fill="#811818" />
            <path d="M142.753,35H.065l23.59-17.476L0,0H142.753Z" fill="#b51c1c" />
          </svg>
        </div>
        <ul>
          <li>TEXT</li>
          <li>TEXT</li>
          <li>TEXT</li>
          <li>TEXT</li>
        </ul>
      </div>
    </div>
  </div>
</div>
johannchopin
  • 13,720
  • 10
  • 55
  • 101
  • 1
    @executable If you take a look at his answer you will see that it's not the expected result -> https://jsfiddle.net/wvgxqhn0/2/ – johannchopin Feb 13 '20 at 12:58
1

Just replace the CSS that I have added.

In this, I just give the position: relative to the ".col" class and adjust the position of the SVG icon.

.container{
    margin-left: 6%;
    margin-right: 6%;
}

.wrapper{
    flex-grow: 1;
    border-left: 2px solid gray;
    border-right: 2px solid gray;
    border-bottom: 2px solid gray;
}

.svg_position{
    background: blue; 
    width: 150px; 
    height: auto; 
    position: absolute; 
    right: -34px;
    top: 66px;
}

.row{
    display: flex;
}

.col {
    flex: 1;
    padding: 1em;
    display:flex;
    flex-direction:column;
    postion: relative;
}

div.box_header{
    background-color: gray;
    color: white;
    display: flex;
}

@media (max-width: 991px) {
    .row{
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    .col{
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        margin-right: 0;
    }
}
<div class="container">
    <div class="row">
        <div class="col">
            <div class="box_header">
                <p>COL 1</p>
            </div>
            <div class="wrapper">
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
        <div class="col">
            <div class="box_header">
                <p>COL 2</p>
            </div>
            <div class="wrapper">
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
        <div style="background: red;" class="col">
            <div class="box_header">
                <p>COL 3</p>
            </div>
            <div style="background: green" class="wrapper">
                <div class="svg_position">                 
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142.753 58.5">
                        <path d="M142.753,35l-49,23.5v-47Z" fill="#811818" />
                        <path d="M142.753,35H.065l23.59-17.476L0,0H142.753Z" fill="#b51c1c" />
                    </svg>
                </div>
                <ul>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                    <li>TEXT</li>
                </ul>
            </div>
        </div>
    </div>
</div>
amit kumar
  • 44
  • 2