Solved

Input box with rotated labels

Posted on 2013-06-03
5
389 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
ID: 39216059
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
ID: 39216147
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
ID: 39216196
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
ID: 39216503
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
ID: 39216634
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

786 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