Home > database >  How to wrap divs with brackets using CSS?
How to wrap divs with brackets using CSS?

Time:04-13

I'm using Vue and Vuetify in an RTL app. I'm trying to create the following layout:

enter image description here

Basically you have two brackets that wrap a text and three buttons (each leads to different locations but currently I used the same button for simplicity).

What I currently got:

<template>
  <v-dialog
    v-model="showModal"
    @click:outside="handleClose"
    outlined
    width="750"
  >
    <v-card>
      <div>
        <div style="float: left; width: 33%;">{</div>
        <div style="float: left; width: 34%;">
          <p>TEXT</p>
          <div>
            <v-btn fab dark target="_blank" rel="noopener">
              <v-icon>mdi-hand-heart-outline</v-icon>
            </v-btn>
            <v-btn fab dark :target="_blank" rel="noopener">
              <v-icon>mdi-linkedin</v-icon>
            </v-btn>
            <v-btn fab dark target="_blank" rel="noopener">
              <v-icon>mdi-github</v-icon>
            </v-btn>
          </div>
        </div>
        <div style="float: left; width: 33%;">}</div>
        <br style="clear: left;" />
      </div>
    </v-card>
  </v-dialog>
</template>

What I got:

enter image description here

Having trouble designing this template. How can I make the brackets bigger with a fixed size that always matches the size of the text and the buttons? Also, not sure why, he left bracket looks to the other side (guessing due to RTL).

CodePudding user response:

You can use ::before and ::after for the brackets. I'm not sure about the size of the brackets but you can adjust them depending of the screen size with media queries.

.container::before{
  content:"{";
  font-size:5rem;
}
.container::after{
  content:"}";
  font-size:5rem;
}
.content{
  display:inline-block;
}
.text{
  text-align: center;
}
  <div >
    <div >
      <div >Text</div>
      <button>a</button>
      <button>c</button>
      <button>b</button>
      <div >Hi</div>
    </div>
  </div>

CodePudding user response:

An alternative to using plain text for the brackets could be an inline svg as so:

.content {
  padding: 10px;
}
.brackets {
  display: flex;
}
.brackets::before, .brackets::after {
  content: '';
  width: 20px;
  background: url('data:image/svg xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iMzIiIGhlaW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-size: 100% 100%;
}
.brackets::after {
  transform: scaleX(-1);
}
<div >
  <div >
    <div>Hello</div>
    <button>Foo</button>
    <button>Bar</button>
    <button>Baz</button>
  </div>
</div>

  • Related