Solved

Input box with rotated labels

Posted on 2013-06-03
5
398 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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 style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

856 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