Solved

Input box with rotated labels

Posted on 2013-06-03
5
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bootstrap wrap text 1 35
ASP.net Markup for Sub Menu 2 45
Allow a tab area under the contents 1 25
Html split(text) Part2 6 23
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

726 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