-3

I am writing simple application that has a login form and I want to make the username and password fields more fancy. And more specifically something like this:

enter image description here

This is from a picture. If it was on the web I would check the html but it was not. I wonder if someone could help with the css because I am not very confident using CSS.

jbutler483
  • 24,074
  • 9
  • 92
  • 145
mathinvalidnik
  • 1,566
  • 10
  • 35
  • 57
  • This combines CSS gradients, the triangle thingy, a background-image texture, borders and border-radius to make round corners... So you'll need to fully learn CSS to do that. [Try a tutorial.](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started) – Domino Mar 18 '15 at 17:28

1 Answers1

2

You could use a pseudo element for this:

.input {
  margin: 5px;
  width: 300px;
  height: 30px;
  position: relative;
  border: 2px solid black;
  border-radius: 5px;
}
.label {
  display: inline-block;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  width: 45%;
  background: black;
  color: white;
  text-align: center;
  line-height: 30px;
}
.label:after {
  content: "";
  position: absolute;
  right: -15px;
  top: 5px;
  height: 0%;
  border-left: 15px solid black;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  z-index: 8;
}
.input input[type="text"] {
  position: absolute;
  height: 100%;
  width: 50%;
  left: 50%;
  padding: 0;
  border: none;
  outline: none;
}
<div class="input">
  <div class="label">Username</div>
  <input type="text" placeholder="input here" />
</div>

<div class="input">
  <div class="label">Password</div>
  <input type="text" placeholder="input here" />
</div>
jbutler483
  • 24,074
  • 9
  • 92
  • 145