skip to Main Content

so i am working on a project for my college and I saw a very cool border style that I would like to replicate in my project, but I am having difficulty getting it right. I am using JavaScript, CSS, and React in this project.
How i want
I tried this:

.input-container {
  position: relative;
  width: 22vh;
}

.form-control-sub {
  width: 100%;
  height: 4vh;
  padding: 13px 40px 11px 30px;
  border-radius: 20px;
  border: 5px solid var(--cor-principal);
  background-color: transparent;
  font-family: Poppins;
  font-size: 1.6vh;
  font-weight: 800;
  text-align: center;
  color: var(--cor-secundaria);
  position: relative;
}

.form-control-sub.data {
  border-top-left-radius: 0px;
  border-top-right-radius: 0px;
  border-radius: 20px;
  border-top-style: dashed;
  border-image: fill;
}

.data_label {
  position: absolute;
  top: -10px;
  left: 10px;
  padding: 0 5px;
  color: var(--cor-secundaria);
  font-family: Poppins;
  font-weight: 800;
  z-index: 1;
}

.data_label.cadastro {
  left: 59.5%;
}

and i get this:

How it is

2

Answers


  1. just keep the top container box has a normal border.likeborder: 1px solid black.then place a box on the left-top side,set it`s position as absolute, also set its background color,make sure the left-top box can cover the boder.

    Login or Signup to reply.
  2. I have created a codepen, just refer it for your desired ui.
    Hope it helps

    body {
      background-color: #2c3333;
      display: flex;
      height: 100vh;
      justify-content: center;
      align-items: center;
      box-sizing: border-box;
      border: 0;
      margin: 0;
      padding: 0;
      font-family: Verdana;
    }
    input {
      border: 0;
      background-color: transparent;
      outline: none;
      color: #fff;
      font-size: 24px;
      font-weight: 900;
      text-align: center;
      width: 100%;
    }
    
    .input-container {
      border: 5px solid #fff;
      width: 300px;
      border-radius: 10px;
      padding: 10px;
      position: relative;
    }
    label {
      position: absolute;
      top: -15px;
      background-color: #2c3333;
      padding: 0 10px;
      color: #829898;
      font-weight: 900;
      font-size: 20px;
    }
    <html>
      <body>
        <div class="input-container">
          <label>Data Nasc.</label>
          <input type="text" placeholder="DD/MM/AAAA"/>
        </div>
      </body>
    </html>

    Modify it according to your convenience.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search