Solved

Input box with rotated labels

Posted on 2013-06-03
5
370 Views
Last Modified: 2013-06-03
Hi

I have a unordered list of input boxes how can I rotate the labels like an excel spreadsheet

Bellow is some rough code but all this dose is put the boxes inline not rotate the labels, as can be seen the input will only contain one character so the labels will be longer, and need to be in a row.

CSS
.rotate  
{
display: inline;
list-style-type: none;
padding-right: 20px;
}

HTML
<div>
  <ul class = "rotate">
    <li> <input type="text" size ="2" id="one" value="X"><label for="one">label one</label></li>
    <li> <input type="text" size ="2" id="one" value="Y"><label for="two">label two</label></li>
    <li> <input type="text" size ="2" id="one" value="Z"><label for="three">label three</label></li>
  </ul>
</div>

Open in new window

0
Comment
Question by:trevor1940
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
This is the basic css code to rotate but you have to convert the label to a block and fix  your html code to be valid.


  -ms-transform:rotate(270deg); /* IE 9 */
  -moz-transform:rotate(270deg); /* Firefox */
  -webkit-transform:rotate(270deg); /* Safari and Chrome */
  -o-transform:rotate(270deg); /* Opera */

Open in new window

Working Sample http://jsbin.com/ulosop/2/edit
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
  <style>

.rotate  
{

list-style-type: none;

}
    
    
    label{
      display:Block;
      width:30px;
  -ms-transform:rotate(270deg); /* IE 9 */
  -moz-transform:rotate(270deg); /* Firefox */
  -webkit-transform:rotate(270deg); /* Safari and Chrome */
  -o-transform:rotate(270deg); /* Opera */
    }
    
</style>
</head>
<body>
  <div>
  <ul class = "rotate">
    <li><label for="one"><input type="text" size ="2" id="one" value="X">one</label></li>
    <li><label for="two"> <input type="text" size ="2" id="two" value="Y">label two</label></li>
    <li><label for="three"> <input type="text" size ="2" id="three" value="Z">label three</label></li>
  </ul>
</div>
  

  
 
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:trevor1940
Comment Utility
that looks good

apologies for any typos in my code example

if i wanted the output similar to the attached bmp (with out the excel numbering) should i use a table?Required output
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
Yes, I think in this case that would be easier.   This is what tables are designed for.
http://jsbin.com/ayurod/1/edit

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
 <style>
   table{background-color:blue;color:gold;}
      th{
      
     height:60px;
     padding-bottom:10px;
     
  -ms-transform:rotate(270deg); /* IE 9 */
  -moz-transform:rotate(270deg); /* Firefox */
  -webkit-transform:rotate(270deg); /* Safari and Chrome */
  -o-transform:rotate(270deg); /* Opera */
    }
   
   td{background-color:gray;}
  </style>
</head>
<body>
  <table width="400">
  <tr>
    <th>heading 1</th>
    <th>heading 2</th>
    <th>heading 3</th>
  </tr>
  <tr>
    <td>item 1.1</td>
    <td>item 1.2</td>
    <td>item 1.3</td>
  </tr>
  <tr>
    <td>item 2.1</td>
    <td>item 2.2</td>
    <td>item 2.3</td>
  </tr>
    </tr>
  
</table>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:trevor1940
Comment Utility
Thanx
btw I'm converting excel spredsheet into a Database with a web front end  this part just contains a single letter which the user may alter
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
If you are not using this for a public website you could might be able to get away with saving your excel as html and trying that.  However, the html microsoft produces works great for printing but terrible for the web.  I think it may be fine where you are sharing with just a few people and it may or may not work.  But if meant for the general public, this is a better solution.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now