How To Make A Vertical Input Field?
Solution 1:
What you're looking for is transform: rotate()
.This takes a value in degrees, so you can rotate either to the left or to the right. rotate(90deg)
goes from top to bottom, rotate(-90deg)
goes from bottom to top.
You'll also probably want to make use of transform-origin
to choose where the rotation gets based from, in order for the rotated text to align at the correct position.
Here's a minimal example:
input[type="text"] {
transform: rotate(-90deg);
transform-origin: left 0;
position: absolute;
bottom: 0;
}
<inputtype='text'placeholder='enter name'>
And here's a (rough) working example. Maximise the snippet to see it positioned correctly. You may need to adapt the positioning based on your page layout.
input[type="text"] {
position: absolute;
bottom: -150%;
left: 25%;
transform: rotate(-90deg);
transform-origin: left 0;
}
form {
position: relative;
}
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
width: 100%;
}
.sidenav {
height: 100%;
width: 20%;
background: #111;
overflow-x: hidden;
box-sizing: border-box;
padding: calc((20% - 50px)/2);
}
.sidenava {
position: relative;
bottom: 18px;
font-size: 90px;
color: #818181;
}
<divclass='sidenav'><form><inputtype='text'placeholder='enter name '><a>×</a></form></div>
Hope this helps! :)
Solution 2:
you may take a look at writing-mode
.
The writing-mode CSS property defines whether lines of text are laid out horizontally or vertically and the direction in which blocks progress.
About MSIE https://msdn.microsoft.com/library/ms531187(v=vs.85).aspx
.sideway {
writing-mode: vertical-rl;
writing-mode: sideways-lr;/* FF*/background: gray;
padding: 0.25em;
vertical-align:top;
}
form {
border: solid gray
}
<form><spanclass="sideway"><inputtype=textplaceholder='enter name'size=8/><inputtype='submit'id='X'/></span></form>
<edit>
Chrome does not apply writing-mode on form element (bug?)
Work around possible: demo
.sideway {
font-size: 3em;
margin: 01em00;
white-space: nowrap;
background: #333;
padding: 0.25em0;
float: left;
width: 2em;
}
.sidewayspan {
vertical-align: top;
display: inline-block;
transform: translatey(100%) rotate(270deg);
transform-origin: 00;
}
.sidewayspan:before {
content: '';
padding-top: 100%;
float: left;
}
input {
font-size: 1em;
color: gray;
background: none;
border: none;
line-height: 0.8em;
vertical-align: middle;
outline: none;
}
[type="submit"] {
font-size: 2em;
vertical-align: middle;
width:1em;
}
form {
overflow: hidden;
border: solid #3330.5em;
}
p {
overflow: hidden;
margin: 1em;
}
<form><pclass="sideway"><span><inputtype=textplaceholder='enter name'size=8/><inputtype='submit'id='submit'value='×'/></span></p><p>whatever else comes in your form</p></form>
Post a Comment for "How To Make A Vertical Input Field?"